0

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

1 に答える 1

0

というコントローラーを作成し、このコントローラー内で ActionResult (または ViewResult) を返すErrorControllerアクション メソッドを作成します。Error

次に、という名前でビューを作成し~/Views/Error/ますerror.cshtml

これで問題は解決します。

于 2011-09-23T14:46:18.397 に答える