2

那是我的代码homecontroller

    public class HomeController : Controller
    {
          [AllowAnonymous]
          public  PartialViewResult FB_InviteFriends()
          {
               return PartialView("~/Views/ListContats/_fbinvite.cshtml");
          } 
          [Authorize]
          public ActionResult YourZone()
          {
               return View();
          }
    }

我想通过使用此 url 访问FB_InviteFriends()方法public/unAuthorized用户: /Home/yourzone/FB_InviteFriends 但由于 [Authorize] 属性,它会将我重定向到登录页面。现在我的问题是,有什么方法可以避免授权,而无需删除[Authorize]我需要的属性yourzone。任何global.asax过滤器 任何可能有帮助的路由过滤器。

4

1 回答 1

3

Add an exception to authorization for this path, e.g.

  <location path="Home/yourzone/FB_InviteFriends">    
    <system.webServer>
      <security>
        <authentication>
          <windowsAuthentication enabled="false" />
          <anonymousAuthentication enabled="true" />
        </authentication>
      </security>
    </system.webServer>
  </location>

you may have to adjust according to what authentication you use on your site.

于 2014-02-25T11:53:54.013 回答