Wednesday, 25 April 2012
05:20 PM
In ASP.NET Web Pages/Razor, you use the @ character inside markup to mean "here be code." Like this:
<p>@DateTime.Now</p>
But suppose you want to display the @ character instead of use it to mark code? Like this:
<p>You use the @ character to mark inline code.</p>
Try that in a .cshtml page and you're rewarded with a YSOD:
(Click to embiggen)
Simple fix: escape the @ character with ... another @ character. Like this:
<p>You use the @@ character to mark inline code.</p>
This makes the parser happy.
(h/t, as usual with parser questions: Andrew Nurse)
[categories]
aspnet, webmatrix
|
link
|