In my MVC application, I call the HttpUnauthorizedResult class and specify the statusDescription parameter.
if (!canAdd) { return new HttpUnauthorizedResult("You do not have access to add"); }
This also redirects the Login method to AccountController and then redirects them to the appropriate screen.
public ActionResult Login(string returnUrl) { if (WebSecurity.IsAuthenticated) { return RedirectToAction("AccessDenied"); } ViewBag.ReturnUrl = returnUrl; return View(); }
My question is how can I use the Status Descripton parameter, it would be nice to display this data in the AccessDenied view.
source share