如何阻止IIS7的扑灭了自己的404我的MVC应用程序得到一个机会来处理它之前? [英] How do I stop IIS7 from putting out its own 404 before my MVC app gets a chance to handle it?
问题描述
我有一个ASP.NET MVC 2应用程序,它在Global.asax中的Application_Error事件。在此,我检测,其中异常类型是这样HttpException和HTTP code为404,并重定向到我自己的404处理页。
I have an ASP.NET MVC 2 application, which has an Application_Error event handler in global.asax. In this, I'm detecting the case where the Exception type is HttpException and the HTTP code is 404, and redirecting to my own 404-handling page.
这工作正常我的卡西尼开发服务器上,但现在我想将其移动到具有IIS7我的生产服务器(使用集成模式)。
This works fine on my Cassini development server, but now I'm trying to move it over to my production server which has IIS7 (using integrated mode).
当我要求一个不存在的URL,IIS7正显示出了自己的404页,到目前为止,我所知道的,我的Application_Error方法不会被调用。
When I request a non-existent URL, IIS7 is showing its own 404 page, and so far as I can tell, my Application_Error method is never called.
我该如何解决呢?
推荐答案
我回答说,在另一篇文章:
<一href=\"http://stackoverflow.com/questions/3166523/asp-net-application-hosted-on-iis7-that-is-ignoring-custom-errors-and-falls-back/3275580#3275580\">ASP.NET托管于IIS7被忽略的自定义错误和应用程序回落到IIS错误
I answered that in another post: ASP.NET Application hosted on IIS7 that is ignoring custom errors and falls back to IIS errors
禁用IIS错误信息,你必须设置
"To disable the IIS error messages you have to set
Response.TrySkipIisCustomErrors = true;
在您的错误页面。在这之后,你的错误消息应该显示没有问题。
in your error page. After that, your Error messages should show without problem."
这篇关于如何阻止IIS7的扑灭了自己的404我的MVC应用程序得到一个机会来处理它之前?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!