What's the difference between these 2 in Razor? I find that I can accomplish the same, whether I use @:
or <text>
.
The @: sequence indicates that the line of content that follows should be treated as a content block: ("razor at colon" in Google).
This operator is useful in conjunction with other Razor server side operators when you want to output something as a literal text. For example: @if (model. Foo) { @:Some text to be written directly. }
The difference between them is that View Pages are Razor views that are used to provide the HTML representations (aka views) for services in much the same way View Pages work for MVC Controllers.
A Razor Page is almost the same as ASP.NET MVC's view component. It has basically the syntax and functionality same as MVC. The basic difference between Razor pages and MVC is that the model and controller code is also added within the Razor Page itself. You do not need to add code separately.
Scott Guthrie wrote about both on his blog. His answer basically boils down to <text>
supports multiple lines, while @:
is meant to be a more compact form for a single line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With