views:

18

answers:

2

I am creating ASP.Net MVC application and want to handle errors globally. I have set web.config value as mode=On and defaulRedirect="Error.aspx". I have Error.aspx at two places. One at Views/Shared folder and one at project root folder level. But each time an unhandled error occurs, the error page at root level gets called. How can I make it redirect to the one at Shared folder level?

I want to do this becasuse, currently I am getting error as "could not load type System.Web.Mvc.ViewPage" when any error is occuring.

Regards, Anil

A: 

If it is an mvc app, the best bet is to implement your error page in MVC with a controller and view. Create an "Error" controller, and return the appropriate view from there. Then in web.config, just point at defaultRedirect="Error". Let the MVC routes handle it from there.

Stephen M. Redd
A: 

Hello,

"defaulRedirect" looks like a spelling error to me.

However, if there is an error that is handled by your web.config file, you should specify the path to the page you would like to display, which in the case of ASP.NET MVC is a routing rule...

The following blog post supplies a full example.

http://www.genericerror.com/blog/2009/01/27/ASPNetMVCCustomErrorPages.aspx

Sohnee