このコードを考えてみましょう。
protected void Application_Start()
{
InitLogger();
InitAppContext();
AreaRegistration.RegisterAllAreas();
// WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
}
InitLogger で例外が発生したとします。
これを処理するための 2 つの解決策があります。
- Application_Error イベントを使用して、リクエストを特定のページにリダイレクトします。このアプローチを試すと、
Request is not available in this context
- を使用し
<customErrors mode="On" defaultRedirect="Error.html" />
ます。私が彼を試してみると、私は得ますhttp://localhost:1937/Error.html?aspxerrorpath=/
説明されている状況をどのように処理しますか?
ありがとう。
PS: コントローラーの例外 (http の例外とカスタムの例外) を処理するために、フィルターを使用しました。その部分は完了です。