2

How can I add the @ symbol to a razor view without it trying to rendor it? The reason I ask is that in my footer I have some latest tweets and it shows the twitter username in the format @username but MVC is trying to parse it as code and throws a compilation error because @username does not exist in the current context (obviously).

Any help would be great

DaveDev
  • 41,155
  • 72
  • 223
  • 385
r3plica
  • 13,017
  • 23
  • 128
  • 290

4 Answers4

5

Escape it with an extra @. Example:

@@TwiterName

Another solution is to use the following tags: <text></text>

Max
  • 12,622
  • 16
  • 73
  • 101
2

Try using this @@, voila the trick.

Softlion
  • 12,281
  • 11
  • 58
  • 88
2

you may use <text>@name</text> or @@ will work.

Zaheer Ahmed
  • 28,160
  • 11
  • 74
  • 110
1

Just like how the \\ works which displays as \ when printed on a console, use @@ and then concat characters if that's what you need to display a single @

Jon P
  • 826
  • 1
  • 7
  • 20