开发者

Will the URL /nosuchpage get routed via my ASP.NET MVC application?

[I'm trying to figure out the reason why I'm having another problem, and this question is part of the puzzle.]

I have an MVC 2 website that has routing set up so that URLs such as /Customer/23/Order/47 get handled by various controllers. I do not have a rule that would match, for example, /nosuchpage and in my Cassini environment a request 开发者_StackOverflowfor that URL will trigger my Application_Error code, which lets me log the error and show a friendly response.

However, when I deployed this website on IIS7 using integrated mode, my Application_Error is not triggered, and IIS shows its own 404 message. No matter what I've tried, I can't get Application_Error to fire.

Now I'm thinking: is the reason it doesn't fire because the request is not getting routed via my application? Either because I didn't explicitly set up a catch-all route, or because the file-extension fools it into thinking it should use the "static file handler" (whatever that is)?

Should I expect my Application_Error to be invoked?


The setting you need in your web.config is

<system.webServer>
  ...
  <httpErrors errorMode="Detailed" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜