Reputation: 44275
This question feels ridiculous...I wrote literal text in Index.cshtml:
<div> blah blah blah <HereBeSomeText>. Blahdy friggen blah.</div>
How do I escape or write out <HereBeSomeText>
so that it is displayed as content on the page rather than interpreted as bad HTML?
Upvotes: 2
Views: 313
Reputation: 60190
Just use the common entities for <
and >
:
<div> blah blah blah <HereBeSomeText>. Blahdy friggen blah.</div>
Upvotes: 1
Reputation: 156524
While I'm not a Razor expert, it seems like something like this ought to work:
<div>
@"blah blah blah <HereBeSomeText>. Blahdy friggen blah."
</div>
or
<div>
@new HtmlString(
Html.Encode("blah blah blah <HereBeSomeText>. Blahdy friggen blah."))
</div>
The actual HTML produced would be something like:
<div>
blah blah blah <HereBeSomeText>. Blahdy friggen blah.
</div>
... in which the browser would convert < and > to <
and >
respectively.
Upvotes: 0