forum

Home / DeveloperSection / Forums / Require authorization within whole ASP .NET MVC application

Require authorization within whole ASP .NET MVC application

marcel ethan 1951 15-Jan-2015

I create application where every action beside those which enable login should be out of limits for not logged user.

Should I add [Authorize] annotation before every class' headline? Like here:

namespace WebApplication2.Controllers {
[Authorize]
    public class HomeController : Controller {    
        public ActionResult Index() {
            return View();
        } 
        public ActionResult About() {
            ViewBag.Message = "Your application description page."; 
            return View();
        } 
        public ActionResult Contact() {
            ViewBag.Message = "Your contact page.";
 
            return View();
        }
    }
}

or there is a shortcut for this? What if I want to change rules for one and only action in particular controller?


Updated on 15-Jan-2015

Can you answer this question?


Answer

1 Answers

Liked By