Razor ViewEngine:我如何摆脱“@"象征? [英] Razor ViewEngine: How do I escape the "@" symbol?

查看:19
本文介绍了Razor ViewEngine:我如何摆脱“@"象征?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 ASP.NET MVC3 中结合 Twitter @Anywhere API 输出一些 Twitter 句柄,但我无法弄清楚如何在 Razor 视图中实际转义@"符号.

I'm trying to output some Twitter handles in ASP.NET MVC3 in conjunction with the Twitter @Anywhere API, and I haven't been able to figure out how to actually escape the "@" symbol in a Razor view.

有谁知道在 Razor 中转义@"字符的语法是什么?

Does anyone know what the syntax is for escaping the "@" character in Razor?

我尝试过使用 </text> 并导致 JIT 错误.

I've tried using <text></text> and that results in a JIT error.

推荐答案

你必须使用@@ 来转义@符号.

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

需要注意的一件重要事情是,当 @ 符号存在于电子邮件地址中时,您无需对其进行转义.Razor 应该足够聪明,可以自己解决这个问题.

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.

这篇关于Razor ViewEngine:我如何摆脱“@"象征?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆