私の MVC アプリケーションでは、HttpUnauthorizedResult クラスを呼び出し、statusDescription パラメーターを指定します。
if (!canAdd) {
return new HttpUnauthorizedResult("You do not have access to add");
}
これにより、AccountController の Login メソッドもリダイレクトされ、適切な画面にリダイレクトされます。
public ActionResult Login(string returnUrl)
{
if (WebSecurity.IsAuthenticated)
{
return RedirectToAction("AccessDenied");
}
ViewBag.ReturnUrl = returnUrl;
return View();
}
私の質問は、Status Descripton パラメーターをどのように活用するかということです。これらの詳細を AccessDenied ビューに表示するとよいでしょう。