ASP.NET MVC2 CrAzY Characters in View Output
This is what I did to get around the issue. I'm still trying to find a better way. Place the following code in the global.asax.cs
protected void Application_PreSendRequestHeaders()
{
HttpResponse response = HttpContext.Current.Response;
if (response.Filter is GZipStream && response.Headers["Content-encoding"] != "gzip")
response.AppendHeader("Content-encoding", "gzip");
else if (response.Filter is DeflateStream && response.Headers["Content-encoding"] != "deflate")
response.AppendHeader("Content-encoding", "deflate");
}
Update Check out the following link for some more information where Rick uses the following to solve the issue. Place the following in your global.asax.cs
protected void Application_Error(object sender, EventArgs e)
{
// Remove any special filtering especially GZip filtering
Response.Filter = null;
}
http://www.west-wind.com/weblog/posts/2011/May/02/ASPNET-GZip-Encoding-Caveats
This looks like it might be an issue with invalid character set encoding being used on the response?
what encoding are you using? Unicode/UTF8 or an asian character set?
No, it's not an invalid character set issue; I've had this happen before. What's happening is that you're deflating the content and somehow (either an exception occurs, you're forgetting to, etc) not setting the compression method you used in the headers.
Now, to actually solve the problem, you have a couple of options:
Application_PreSendRequestHeaders
chek to see if the content is delfated and the headers are missing; you can either deflate the content or add the headers. Hope that helps.
链接地址: http://www.djcxy.com/p/46708.html上一篇: 为我的网站建立具有一些四方特征的服务