Change the action in AuthorizeAttribute filter
If a user is not authorized to execute an action, in HandleUnauthorizedRequest
, I redirect the user to the error action. This results in a 302 error.
For example from /Home/Index
, the user would be taken to /Error/Unauthorized
.
Instead of the redirect, how do I change the ActionResult
in the filterContext.Response
so that the user sees the unauthorized page withou开发者_高级运维t a redirect?
filterContext.Response = new ViewResult
{
ViewName = "~/Views/Error/Unauthorized.cshtml"
};
精彩评论