[ACCEPTED]-Razor ViewEngine: How do I escape the "@" symbol?-twitter-anywhere
You have to use @@ to escape the @ symbol.
One 5 important thing to notice is that you DO 4 NOT need to escape the @ symbol when it 3 exists within an email address. Razor should 2 be smart enough to figure that out on its 1 own.
If you are adding Twitter meta tags
and your 2 Twitter username is, say, foobar
it should look 1 like this
<meta name="twitter:site" content=@("@foobar")>
if you need to comment @ symbols in css 1 code and just @@ wont work, use this:
@("@@font-face"){ ... css ...}
I had yet another odd case: pass '@' + @Model.SomeProperty
to a link 5 href.
The best solution for this case was 4 given IMO in this answer to a similar question. Both 3 @@
and @:
didn't work while using the html code 2 @
would complicate things.
So, my code was 1 <a href="~/path/?query=@('@')@Model.SomePropery">
@Html.Raw('@')@Model.SomePropery
would have worked as well.
If you are adding Schema.org JSON-LD Tags, @Matt's 1 answer worked for me:
....
@("@context"): "https://schema.org",
....
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.