开发者

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"
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜