【问题标题】:Change the action in AuthorizeAttribute filter更改 AuthorizeAttribute 过滤器中的操作
【发布时间】:2011-10-08 00:38:53
【问题描述】:

如果用户无权执行操作,在HandleUnauthorizedRequest 中,我将用户重定向到错误操作。这会导致 302 错误。

例如从/Home/Index,用户将被带到/Error/Unauthorized

我如何更改filterContext.Response 中的ActionResult 而不是重定向,以便用户在没有重定向的情况下看到未经授权的页面?

【问题讨论】:

    标签: asp.net asp.net-mvc actionresult authorize-attribute


    【解决方案1】:
    filterContext.Response = new ViewResult
    {
        ViewName = "~/Views/Error/Unauthorized.cshtml"
    };
    

    【讨论】:

      猜你喜欢
      • 2012-10-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多