MVC 4 Authentication
Posted
by Aligned
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Aligned
Published on Thu, 30 Aug 2012 11:20:11 GMT
Indexed on
2012/08/30
21:39 UTC
Read the original article
Hit count: 181
First: After searching for awhile to figure out what’s new/different with MVC 4 and forms authentication, this is the best article I've found on the subject:
Some quotes from the article:
- “The ASP.NET Web Pages team designed SimpleMembership to (wait for it) simplify the task of dealing with membership”
- "WSAT is built to work with ASP.NET Membership, and is not compatible with Simple Membership.
There are two main options there:
- Use the WebSecurity and OAuthWebSecurity API to manage the users and roles
- Create a web admin using the above APIs
- Since SimpleMembership runs on top of your database, you can update your users as you would any other data - via EF or even in direct database edits (in development, of course)"
- “If you want to use an existing ASP.NET Membership Provider in ASP.NET MVC 4, you can't use the new AccountController. You can do a few things:”
- “Universal Providers do not work with Simple Membership.” ~ this post (look for Bob.at.SBS’s answer) says Universal Providers is not needed for MVC 4 to work in Azure)
I've been trying to figure out the Forms Authentication in MVC4. It's different than the past approach (aspnet_regsql). If you do file new project -> MVC 4 -> internet application, you get a really nice template with the controller and model setup for you. However, the tables are different than using aspnet_regsql and the ASP.Net Configuration tool (WSAT) wasn’t connecting to the data I had (it was creating an App_Data/aspnet.mdf file, which I didn’t see right away).
Points of Note
- The database tables are created in the SimpleMembershipInitializer class, when you first run your app using Entity Framework 5 migration functionality.
- The tables created are webpages_Membership, webpages_OAuthMembership, webpages_Roles, webpages_UsersInRoles, UserProfile.
- Web.config settings don’t seem to be needed.
Scott Hanselman on Universal Providers was also useful if not somewhat out dated. Universal Providers and SimpleMembership are not compatible.
http://www.asp.net/web-pages/tutorials/security/16-adding-security-and-membership – walk-through
© Geeks with Blogs or respective owner