Is it possible to disable authorization on one action in an MVC controller?

Total Post:2

Points:14
C#
 258  View(s)
Ratings:
Rate this:

I want to disable authorization in one action. I have added authorize attribute at the controller level

[Authorize]
public class HomeController : Controller
{
    public ActionResult Register()
    {
        return View();
    }
    public ActionResult Login()
    {
        return View();
    }
}

thanks in advance..

  1. Post:10

    Points:70
    Re: Is it possible to disable authorization on one action in an MVC controller?

    You have to use  [AllowAnonymous] attribute

    [Authorize]
    public class HomeController : Controller
    {
        public ActionResult Register()
        {
            return View();
        }
    [AllowAnonymous]
        public ActionResult Login()
        {
            return View();
        }
    }


Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!