私はこの質問に感謝は少し古いですが、これは、誰かを助けることが表示されます。
401の場合は、web.configのcustomerrorsセクションに401を追加した場合でも、おそらく標準の401 Unauthorizedページが表示されます。私は、IISとWindows認証を使用すると、ASP.NETがリクエストを見る前にチェックが行われるので、カッシーニとIIS上の空白のページが表示されることを理解しています。
私のプロジェクトでは、Global.asaxファイル401エラーのために作成したルートにリダイレクトし、ユーザーに「この権限がないことを確認する」ビューを送信します。 Global.asaxの中
:
void Application_EndRequest(object sender, System.EventArgs e)
{
// If the user is not authorised to see this page or access this function, send them to the error page.
if (Response.StatusCode == 401)
{
Response.ClearContent();
Response.RedirectToRoute("ErrorHandler", (RouteTable.Routes["ErrorHandler"] as Route).Defaults);
}
}
とRoute.configで:
routes.MapRoute(
"ErrorHandler",
"Error/{action}/{errMsg}",
new { controller = "Error", action = "Unauthorised", errMsg = UrlParameter.Optional }
);
とコントローラで:
public ViewResult Unauthorised()
{
//Response.StatusCode = 401; // Do not set this or else you get a redirect loop
return View();
}
のようなあなたのアクションコントローラであなたの「フラグ」を追加カスタムページ?または私はちょうど標準のIIS 401のページを参照する必要がありますか? –
401が表示されます。 –