问题描述
我有在IIS 8.5和部署后在本地运行,在Azure网站的ASP.NET MVC 5 Web应用程序 - 在这两种情况下,将在后面描述的行为是一样的。
。我在web.config配置以下的自定义错误页管理(它涵盖了我的自定义错误的所有情况下,它已经过测试,它的工作伟大):
< system.webServer>
< httpErrors errorMode =自定义existingResponse =替换>
<清/>
<错误状态code =400responseMode =ExecuteURL路径=/应用/错误/>
<错误状态code =403responseMode =ExecuteURL路径=/应用/错误/禁止/>
<错误状态code =404responseMode =ExecuteURL路径=/应用/错误/ NOTFOUND/>
<错误状态code =500responseMode =ExecuteURL路径=/应用/错误/>
< / httpErrors>
< /system.webServer>
另外,我有同样的Web.config中配置一个像这样的HTTP模块:
< system.webServer>
<模块>
<添加名称=ImageProcessorModuleTYPE =ImageProcessor.Web.HttpModules.ImageProcessingModule,ImageProcessor.Web/>
< /模块>
< /system.webServer>
这是我的问题是这样的:如果我做喜欢到一个陌生的URL请求 ... / C<
,应用程序执行的500定制在web.config文件中指示错误的路径。
但是,如果我在做一个陌生人URL的请求(模拟一个html标记),如 ... / c为C
,虽然导致错误500,不再被执行自定义错误,因为据此来详细的错误,HTTP模块可以截取电话和决定只显示YSOD ...
这是我得到的消息是:
And is easy to see that this is caused by the webmodule because of the stacktrace:
If I'm commenting out the Image Processor Module from the web.config, everything runs as expected.
Why in this case, the custom error path doesn't get executed?
Thank you for your time and answers.
I very strongly suspect this is a bug in Image Processor.
The exact same issue was reported in Client Dependency (a module for Umbraco) which, while completely unrelated, is similar in that it was accessing Context.Request.RawUrl
at the same stage of the request pipeline.
You have two options:-
Find a way to set
runAllManagedModulesForAllRequests="false"
without impacting the behaviour of your http modulesSee if you can submit a patch to https://github.com/JimBobSquarePants/ImageProcessor/blob/f4080c3217107eb7a571eb69e54cc5e69e1c892c/src/ImageProcessor.Web/HttpModules/ImageProcessingModule.cs to use
Request.Unverified.RawUrl
instead ofRequest.RawUrl
这篇关于HTTP模块截获请求,并打破了自定义错误配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!