开发者

Redirect to Error page in mvc

开发者 https://www.devze.com 2023-01-15 18:28 出处:网络
I working in mvc 2 and need to redirect on error page with exception mesage. For this I have i have override OnException () actionof controller

I working in mvc 2 and need to redirect on error page with exception mesage.

For this I have i have override OnException () action of controller and trying to do like " View("Error").ExecuteResult(this.ControllerCont开发者_StackOverflow中文版ext);" but it is throwig exception 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper"

please give me the right solution

Regards Munish


The HandleError attribute redirects to the Error page that is placed in the shared folder. This page has a model of type System.Web.Mvc.HandleErrorInfo which contains an Exception property. You should modify the Error page so that it displays the exception information you want, like for example <%:Model.Exception.Message %>.

Also make sure that you have the <customErrors mode="On" /> inside the <system.web> in the web.config file otherwise, during development the HandleErrorAttribute won´t intercept the exceptions.

Good luck!

0

精彩评论

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

关注公众号