开发者

Asp.net MVC 3 view engine error

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);


create a controller called ErrorController and inside this controller create an action method called Error which returns an ActionResult (or ViewResult).

Then create a view under ~/Views/Error/ called error.cshtml.

This will solve your problem.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜