I’m creating a web application using ASP.NET MVC 4 and C#.
I want all users to be logged in before using application.
I’m using ASP.NET Membership with a custom database.
One method is check if Membership.GetUser() is null or not in every function.
But isn’t there any easier way than checking user login state in every function? (maybe checking in web.config, global.asax, etc…??)
Sure, decorate your actions or the whole class with
[Authorize]and it will require that the user is logged in first.