Asp.net MVC 3视图引擎错误
我正在尝试在 Application_Error 中进行全局级别的自定义错误处理。
Exception ex = Server.GetLastError();
Server.ClearError();
AssortmentDefinitionLogManager.LogException(ex);
Context.RewritePath("/Error/Error");
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(Context);
但我收到这个错误
Error Message - The view '~/Views/Shared/Error' or its master was not found or no view engine supports the searched locations.
我也尝试过这个
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
var redirectUrl = urlHelper.Action("Error", "Error");
Response.Redirect(redirectUrl);
I am trying for custom error handling at global level in Application_Error.
Exception ex = Server.GetLastError();
Server.ClearError();
AssortmentDefinitionLogManager.LogException(ex);
Context.RewritePath("/Error/Error");
IHttpHandler httpHandler = new MvcHttpHandler();
httpHandler.ProcessRequest(Context);
But i get this error
Error Message - The view '~/Views/Shared/Error' or its master was not found or no view engine supports the searched locations.
I have also tried this
var urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
var redirectUrl = urlHelper.Action("Error", "Error");
Response.Redirect(redirectUrl);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个名为
ErrorController
的控制器,并在该控制器内创建一个名为Error
的操作方法,该方法返回 ActionResult(或 ViewResult)。然后在
~/Views/Error/
下创建一个名为error.cshtml
的视图。这将解决您的问题。
create a controller called
ErrorController
and inside this controller create an action method calledError
which returns an ActionResult (or ViewResult).Then create a view under
~/Views/Error/
callederror.cshtml
.This will solve your problem.