Razor ViewEngine: How do I escape the "@" symbol? Razor ViewEngine: How do I escape the "@" symbol? asp.net asp.net

Razor ViewEngine: How do I escape the "@" symbol?


You have to use @@ to escape the @ symbol.

One important thing to notice is that you DO NOT need to escape the @ symbol when it exists within an email address. Razor should be smart enough to figure that out on its own.


If you are adding Twitter meta tags

and your Twitter username is, say, foobar

it should look like this

<meta name="twitter:site" content=@("@foobar")>


if you need to comment @ symbols in css code and just @@ wont work, use this:

@("@@font-face"){ ... css ...}