[英]redirect from Application_Error
How can I redirect to another page from Application_Error
? 如何从
Application_Error
重定向到另一个页面?
At present i am doing 目前我正在做
Response.Redirect("~/Account/LogOn");
but i would like to do some thing like RedirectToAction()
但我想做一些像
RedirectToAction()
事情
Application_Error is not really a designed way to handle errors in MVC application. Application_Error实际上并不是处理MVC应用程序中的错误的设计方法。
The prefered ways are: 首选方式是:
Some more links that can be helpful: 一些更有用的链接:
Also, I would recommend using ELMAH if you're not using it right now. 另外,如果您现在不使用ELMAH ,我建议您使用ELMAH 。 You can get it as NuGet package.
你可以把它作为NuGet包。
HttpContext.Current.Response.RedirectToRoute(...)
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext).Action("ServerError", "Error");
Response.Redirect(urlHelper, true);
更不用说一个不应该重定向错误 - 你不想在那里发送HTTP 3xx标题,当事情真的全面发生时,你可能会有令人讨厌的重定向循环。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.