Friday, August 6, 2010

Placing Error Views in appropriate directory

At the end of my Custom Error Page in ASP.NET MVC, I wrote that

I tried creating an Error folder and custom error files inside that inside the views folder but ended up unsucessfully.

HandleError(ExceptionType = typeof(DivideByZeroException), View = @"Error\MathError")


Reason :-

You can place the "Error" view either in the same directory as your other Controller specific views (for example: \Views\Test for the TestController above), or within the \Views\Shared folder (it will look first for a controller specific error view, and then if it doesn't find one it will look in the shared folder - which contains views that are shared across all controllers).

Help from :-

Scott Gu's ASP.NET MVC Blog


So my syntax View = @"Error\MathError" is wrong. and it should just be MathError, like this HandleError(ExceptionType = typeof(DivideByZeroException), View = "MathError") and MathError.aspx should be inside the directory of my other controller specific Views in my case it is welcome folder

No comments: