ASP.NET MVC > Authentication and Authorization

Mark action method public in secure controller in ASP.NET MVC

How to mark an action method public in secure controller?


To make an action method public in secure controller, we can mark them as Anonymous.

CONTROLLER CODE

[Authorize]
public class AuthorizeController : Controller
  {

         [AllowAnonymous]
          public ActionResult PublicPage()
          {
              return View();
          }
  }

In above case, even if the controller is marked as secure (decorated with Authorize attribute), the PublicPage (the name of method can be anything else) action method will be accessible for all user even without logging in.

 Views: 16123 | Post Order: 80



Write for us






Hosting Recommendations