MVC Area Error Handling
Asked Answered
L

1

6

I have a MVC project set up with 3 areas. In the main project I have error handling set up using custom errors in the web.config.

<customErrors mode="On" defaultRedirect="~/Error/HttpError">
     <error statusCode="404" redirect="~/Error/Http404" />     </customErrors>

This cause the site to redirect to a error controller in the root and then show the error view.

This works OK in the root site, however when I throw an exception in the home controller of one of the area sites it the message below.

Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.

Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".

Is it the case that error handling in the root site cannot be used in the area sites?

Thanks

John.

Lenorelenox answered 9/8, 2010 at 18:9 Comment(0)
D
1

Does the area have it's own web.config that might be setting it's own error handling options? Can you put a breakpoint in Application_OnError to see if another error is occuring (eg. one loading the error page - eg. if you've turned off Buffering, it won't be able to do the redirect)?

You could also try adding the something like this to the main web.config to see if it it makes any difference:

<location path="nameOfArea">
  <system.web>
    <customErrors mode="On" defaultRedirect="~/Error/HttpError" />
  </system.web>    
</location>
Dithyramb answered 28/2, 2011 at 18:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.