Last post Oct 05, 2014 10:55 PM by Summer - MSFT
Oct 02, 2014 06:40 PM|BrettKB|LINK
I created a new MVC 4 project and modified the connectionString slightly to point to a different db table. When I Register a new user the code below uses my existing UserTable and appears to creates 4 additional tables, the UserTable and webpages_Membership
table are the ones I am interested in.
//InitializeSimpleMembershipAttribute.cs private class SimpleMembershipInitializer
using (var context = new UsersContext())
// Create the SimpleMembership database without Entity Framework migration schema
WebSecurity.InitializeDatabaseConnection("DBConnectionString", "UserTable", "UserID", "UserName", autoCreateTables: true);
catch (Exception ex)
throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", ex);
My UserTable contains 3 fields, UserID, UserName, and Password. The webpages_Membership table contains UserID, Password, it also contains other fields that I am not worried about at the moment. When I Register the new user the UserID and UserName are stored
in the UserTable (Password is left blank in this table). The password is encrypted and stored in the webpages_Membership table. I went into SQL server and created some new users with UserIDs, UserNames, and Passwords(not encrypted in this table) My question
is how can I use the existing MVC4 password encryption to take the un-encrypted Password from the UserTable, encrypt it and place it into the webpages_Membership table. Then I will be able to run my project and Log In using a profile that was created directly
in SQL Server.
Oct 03, 2014 03:55 AM|AidyF|LINK
I'm pretty sure whatever you're doing can be done better, if you need additional functionality you should extend the database schema but leave the original membership tables in-tact and still use them, but this thread will show you how you can hash the passwords
(they are hashed, not encrypted)
Oct 05, 2014 10:55 PM|Summer - MSFT|LINK
Welcome to this ASP.NET forum.
According to your description, I know you’d like to encrypt the field in database by MVC4 default encryption.
As far as I know,
this article may be can help you, you could refer to it.
There are some other encryption technology, hope it could helpful for you.
If there’s anything else I can do for you on this matter, please feel free to contact me at any time.