IISExpress乱码HTTP 500错误消息 [英] IISExpress garbled HTTP 500 error message

查看:70
本文介绍了IISExpress乱码HTTP 500错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在IISExpress上从Visual Studio 2010运行一个项目,并且每当抛出500错误时,它将垃圾发送回浏览器,而不是将格式正确的服务器错误消息与异常详细信息一起发送给浏览器.一封包含异常详细信息的电子邮件发送给我,并且这将正确返回所有内容,只有当它到达浏览器时,我才会收到垃圾邮件.让您了解我的意思是垃圾,这就是我得到的.

I'm running a project off Visual Studio 2010 on IISExpress and whenever a 500 error is thrown it sends garbage back to the browser, rather than a properly formatted server error message with the exception details. An email gets sent to me with the Exception details and this returns everything properly, its only when it hits the browser that I get the garbage. To give you an idea of what I mean by garbage, this is what I get.

我不知道为什么它返回给我,而不是我认为带有堆栈跟踪的正常"异常消息.我的项目中的自定义错误已关闭,并且就像我说的那样,我从设置的电子邮件发件人中的应用程序中获取了适当的异常详细信息,但我在浏览器端得到了此信息.

I have no idea why it returns this to me rather than what I would consider a 'normal' exception message with the stack trace. Custom errors in my project are turned off and like I said, I get the proper exception details from the application in an email sender I have set up, but I get this at the browser end.

推荐答案

我最终发现,这是由于应用程序发送了GZipped内容而没有向浏览器指示实际上是GZipped的标头所致,因此它只是转储了二进制内容.通过在我的Global.asax中添加以下内容来解决这个问题

I eventually found out that this was caused by the application sending GZipped contents without the header that indicated to the browser that is was in fact GZipped, so it just dumped the binary content out. I got round this by adding the following to my Global.asax

Sub Application_Error()
    Response.Filter = Nothing
End Sub

这会在发生错误时将过滤器从响应中删除,并显示我的错误消息.

This will strip the filter out of the response when an error occurs, and my error message appears.

通过此博客将全部归功于Rick Strahl发布以获取解决方法.这不是理想的方法,但是它对我有用,这就是我现在真的很烦的事情.

All credit to Rick Strahl with this blog post for the workaround. It's not ideal but it works for me and that's all I am really bothered about right now.

这篇关于IISExpress乱码HTTP 500错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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