When I was playing around with HandleError attribute, I was wondering how to specify an error page other than the one inside Views\Shared\Error.aspx.
For my divide by zero error, I created Custom error page, named MathError in Views/Shared Folder, and set the Handle Error attribute as follows,
In my web.config file setting defaultredirect attribute doesn't matter and if a DivideByZero exception occur in my code then page will be redirected to "MathError.aspx" for all other error it will be Error.aspx.
[HandleError(ExceptionType = typeof(DivideByZeroException), View = "MathError")].
I tried creating an Error folder and custom error files inside that inside the views folder but ended up unsucessfully. may be I am doing something wrong. I tried the following.
HandleError(ExceptionType = typeof(DivideByZeroException), View = @"Error\MathError")
No comments:
Post a Comment