If I’m working on a view in Razor, and I’m currently in a code block and want to output something, how do I do this? To illustrate my question, I’m using echo from PHP below:
<p>
@if (Model.NumberOfWidgets > 100)
{
echo(Model.NumberOfWidgets);
}
else
{
echo("There are loads of widgets.");
}
</p>
So I’m using echo where I want to tell Razor that I’m not doing C# anymore, I’m meaning this should be written to the output. How do I do this?
Edit: I tried Response.Write, but that gets written before the view markup, at the top of the page!
1 Answer