Membership in ASP.Net MVC4

I just started learning ASP.NET MVC (4). For practical purposes, I start with the micro-blogging project. This way it will have a user database. When I create an ASP.Net MVC4 project, it comes with a membership module that already exists (AccountsController.cs, AccountModel.cs and view files).

I do not have a database right now, so I will use EF with the first project / model. I tried to create a sample database application. When I registered the user (with the registration page provided by Asp.Net MVC4), I could not see any user table in my database. I want to know where are the tables containing user information, userrole. I did not find it in my database.

One more thing, should I use MVC4 authentication or create a new table for users?

Help me with this, please.

Regards, Rahul

+4
source share
2 answers

The ASP.NET MVC 4 "Internet Application" project template by default has some default membership features. If you search and update the line below, membership tables will be created in your database if they do not already exist:

WebSecurity.InitializeDatabaseConnection("DefaultConnection", "UserProfile", "UserId", "UserName", autoCreateTables: true); 

more details here:

http://aaron-hoffman.blogspot.com/2013/02/aspnet-mvc-4-membership-users-passwords.html

+2
source

MVC 4 by default uses SimpleMembership, which uses the localSqlServer default connection string specified on your machine.config computers. This creates data in a database located in the App_Data directory of your project.

+2
source

Source: https://habr.com/ru/post/1441345/


All Articles