Use of AllowAnonymous Attribute in ASP.Net MVC ?
AllowAnonymous Attribute that helps you secure an entire ASP.NET MVC 4 Website or Controller while providing a convenient means of allowing anonymous users access to certain controller action.
using System.Web.Mvc;
namespace Store.Controllers
{
//Restricting users to access this Controler
[Authorize]
public class ProductController : Controller
{
//Only authorize users can access this Action Method
public ActionResult Stock()
{
//Your logic here...
return View();
}
// Any user can access this Action Method
[AllowAnonymous]
public ActionResult Details()
{
//Your logic here...
return View();
}
}
}
Happy Coding 🙂



