ASP.NET MVC: Weird characters in error page

后端 未结 1 1261
感动是毒
感动是毒 2020-12-09 16:50

Since I uploaded an updated version of an ASP.NET MVC 1 application to the server, the Yellow Screen of Death has changed to something like this:

��I�%&/m�

相关标签:
1条回答
  • 2020-12-09 17:05

    Most likely the screen you're showing is caused by GZip encoding in your code. You probably are applying a Response.Filter to the GZip/DeflateStream class and intending to encode your content, but then an error occurs and ASP.NET clears your Headers, but leaves the filter intact. The result is that your content is GZip encoded but the browser doesn't decode it because the Content-Encoding header isn't set.

    To fix this add:

    Response.Filter = null
    

    into your Application_Error routine at the top to force any Repsonse filters to clear out.

    Another thing that can screw you up is OutputCaching of GZipped content. If any OutputCaching is applied make sure you have the VaryByCustom option to allow for the different encoding types (none, Gzip, Deflate most likely).

    +++ Rick ---

    0 讨论(0)
提交回复
热议问题