You can use the [AllowAnonymous]
attribute (which is the default in ASP.NET MVC) to override your [Authorize]
attribute
Assuming you have added your customized authorization logic to the default FilterConfig
class:
public class FilterConfig
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new MyCustomAuthorizationAttribute());
}
}
You can override that setting by decorating your controllers/action methods with [AllowAnonymous]
:
// To allow anonymous access to all action methods
[AllowAnonymous]
public class MyController : Controller
{
// Only allow the Index action method to be called anonymously
[AllowAnonymous]
public ActionResult Index()
{
}
}