我homecontroller
的代码。
public class HomeController : Controller
{
[AllowAnonymous]
public PartialViewResult FB_InviteFriends()
{
return PartialView("~/Views/ListContats/_fbinvite.cshtml");
}
[Authorize]
public ActionResult YourZone()
{
return View();
}
}
我希望使用此网址访问FB_InviteFriends()
方法public/unAuthorized
用户:
/Home/yourzone/FB_InviteFriends
但由于[授权]属性,它会将我重定向到登录页面。
现在我的问题是,有什么办法可以避免授权,而不会删除[Authorize]
所需的yourzone
属性。global.asax
。任何{{1}}过滤任何可能有帮助的路由过滤器。
答案 0 :(得分:3)
为此路径的授权添加例外,例如
<location path="Home/yourzone/FB_InviteFriends">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="false" />
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
您可能需要根据您在网站上使用的身份验证进行调整。