I’m building a small app with ASP.NET MVC and I’m using the ASP.NET membership provider for handling users. Hooked this up to the login page of the basic MVC template.
What is the best practice for checking a valid authentication globaly? I basically want to redirect to the front page or the login page if the user’s not authenticated on all my pages.
-anders
The way we did it, back in the days of MVC Preview 4 or so, was to create a new “BaseController” class, which every other controller then inherits from. This BaseController class uses the Authorize attribute
The rest of our controllers then inherited from this one
Haven’t had to work with MVC for a few months now, so I can’t say if this is still applicable, so proceed with caution…