Reputation: 55042
When i setup an MVC 3 project, there is an implementation of user register and login.
I want to be able to password protect the pages with session? How can i do this?
There are similar questions but no details on implementation. If the user is not logged in, user shouldnt be able to access to pages.I want to password protect the pages.How can I implement this?
Upvotes: 1
Views: 247
Reputation: 15190
Just add [Authorize]
attribute to actions that must be not visible to not logged in users.
[Authorize]
public ActionResult Index()
{
return View();
}
Also you can add this attribute to whole controller, so in this case all actions in that controller will be unreachable to not logged in users.
Upvotes: 2