Ren*_*uis 4 .net unicode razor servicestack
我使用ServiceStack(v3.9.44.0)作为Windows服务(目标是.Net4.5),我使用Razor让ServiceStack生成并提供HTML.
事情很好,但有一个奇怪的问题:看起来视图.cshtml中硬编码的unicode字符串没有正确呈现.
这就是我的意思:

项目视图的结构是规范的:

随着_Layout.cshtml:
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<p>Accents in \Views\_Layout.cshtml: à é ë ô</p>
@RenderBody()
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
并且Articles.cshtml:
@inherits ViewPage<List<PrepaService.Article>>
<p>Accents in \Views\Articles.cshtml: à é ë ô</p>
Table with code-injected list of items:
<table>
@foreach(var a in Model) {
<tr>
<td>@a.Description</td>
</tr>
}
</table>
Run Code Online (Sandbox Code Playgroud)
这两个文件都正确保存为无BOM的UTF8文件.
我也尝试添加以下内容,但它不会改变任何内容:
SetConfig(new EndpointHostConfig {
AppendUtf8CharsetOnContentTypes = new HashSet<string> { ContentType.Html }
});
Run Code Online (Sandbox Code Playgroud)
我对所有文件和显式charset=utf-8内容类型定义使用无BOM的UTF8编码.
这适用于渲染的任何内容_Layout.cshtml,以及View模板中代码注入的任何内容
但它不适用于View模板中的硬编码字符串.
| 归档时间: |
|
| 查看次数: |
1280 次 |
| 最近记录: |