在ASP.NET MVC页面上输出的奇怪字符 [英] Strange characters output on asp.net mvc page

查看:91
本文介绍了在ASP.NET MVC页面上输出的奇怪字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时(随机)我的asp.net mvc应用程序输出页面,其中单个字符被奇怪的问号代替,如图所示

Sometimes (randomly) my asp.net mvc application outputs page where single character is being replaced with weird question marks, as shown on image

此行为在数据更改之前一直保持不变,并且不会随着页面刷新而消失.整个页面使用格鲁吉亚unicode.我在Visual Studio 2010和IIS Express中使用了ASP.NET MVC 3.在IIS 7.5的发布站点上也可以观察到这一点.我在asp.net Webforms应用程序中也看到过类似的问题.

This behavior is constant until data changes, and it does not disappear with page refresh. The whole page is in Georgian unicode. I am using asp.net mvc 3 with visual studio 2010 and iis express. This is also observed on published site to IIS 7.5. I have seen similar issues in asp.net webforms application too.

我不仅在数据库提供的数据上观察到了这种行为,而且在使用html helper生成的简单锚点上也观察到了这种情况

I have observed this behavior not only on db-provided data, but simple anchors, generated with html helper

TagBuilder addAnchor = new TagBuilder("a");
addAnchor.AddCssClass("add-item");
addAnchor.MergeAttribute("href", "#");
addAnchor.SetInnerText(SharedResources.Add); //resource item contains string დამატება

输出锚点დამატ ბა"

which output anchor "დამატ���ბა"

由于在原始响应中已经包含了这些符号,因此在浏览器端进行页面渲染不会出现问题.

And this is not issue with page rendering on browser-side, as raw response already contains these symbols.

更新:

看起来,通过设置Response.BufferOutput = false;禁用缓冲区输出会从页面中删除怪异的字符.但是我使用盒式磁带来引用包,它不能与禁用的缓冲区输出一起使用-页面上没有引用任何样式或样式表

As it seems, disabling buffer output by setting Response.BufferOutput = false; removes weird characters from page. But I use Cassette for referencing bundles, and it cannot work with disabled buffer output - no scipts or stylesheets get referenced on page.

你们中有人有类似的问题吗?这实际上对我来说至关重要,因为当前它会影响数据,其中单个字符被损坏是多选测试题的正确答案信息.

Has anyone of you had a similar problem? This is actually critical for me, as currently it affects data where that single character being damaged is the correct answer information of a multi-select test question.

推荐答案

我遇到了相同的错误.它是Cassette,具有重写结果HTML内容的功能(并且需要将BufferOutput设置为true),以便在需要时将引用的脚本和样式表标签移动到顶部. 请参阅 http://getcassette.net/documentation/configuration 上的 IsHtmlRewritingEnabled 选项. . 当我关闭此功能时,该错误已消失.

I had the same bug. It is Cassette with a feature that rewrites the result HTML content (and needs BufferOutput set to true) to move referenced script and stylesheet tags to the top if needed. See the IsHtmlRewritingEnabled option at http://getcassette.net/documentation/configuration. When I turned off this feature, the bug has disappeared.

我的观察:

  1. 仅在远程请求中出现.本地请求总是可以的.
  2. 问号的位置对于所有客户端,浏览器和计算机始终是恒定的.
  3. 问号的位置仅在重新编译应用程序后才会更改.

这篇关于在ASP.NET MVC页面上输出的奇怪字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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