Reputation: 21
that the code for my homecontroller
.
public class HomeController : Controller
{
[AllowAnonymous]
public PartialViewResult FB_InviteFriends()
{
return PartialView("~/Views/ListContats/_fbinvite.cshtml");
}
[Authorize]
public ActionResult YourZone()
{
return View();
}
}
i want to access the FB_InviteFriends()
method public/unAuthorized
users, by using this url:
/Home/yourzone/FB_InviteFriends
but it will redirect me to login page due to [Authorize] attribute.
now my question is that is there any way that i can avoid the Authorization without removing the [Authorize]
attribute as i need it on yourzone
. any global.asax
filter any route filter which may help.
Upvotes: 2
Views: 933
Reputation: 20674
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.
Upvotes: 3