CSS3 @ font-face打破Razor解析器 - 它可以通过变通方法保持内联吗?

Joh*_*n K 23 css3 font-face razor asp.net-mvc-3

CSS3 @ font-face规则使用错误消息打破Razor 部分: CS0103: The name 'font' does not exist in the current context.它在运行时崩溃了.

似乎CSS3 @字符是导致Razor解析器失败的问题.

例:

@section HeadCustomStyleBlock {  
    <style type="text/css">  
        @font-face {  
            font-family: Gentium;
            src: url(http://example.com/fonts/Gentium.ttf);            
        }  
    <style>  
}  
Run Code Online (Sandbox Code Playgroud)

对于上下文,@section HeadCustomStyleBlock它包含在Layout页面的<head>元素中.

我可以实现一种解决方法来保持内联,而不是将其移动到外部文件吗?

Ben*_*eno 40

根据ScottGu的博客:

如果内容作为代码有效(并且您希望将其视为内容),则可以通过键入@@显式地转义@字符.

http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx