For the basic knowledge of the MVC framework, please visit the + + Intelligence podcast, download the relevant getting Started video watch patiently:
Http://net.itcast.cn/subject/tegongnet/index.html
For a knowledge of the previous version of the Microsoft ASP Framework's identity system, please visit =>jesse Liu's blog for reference articles:
Http://www.cnblogs.com/jesse2013/p/membership.html
There has been an article on the internet that has written a chapter on the eunuch's tutorial:
http://www.cnblogs.com/liuhaorain/p/3776467.html
Preparatory work:
First, the basic establishment of the project, the three figure is finished.
Second, please download the. NET Reflector Anti-compilation tool, which is each. NET Developer Essentials: (This is pretty important, a lot of the underlying code to see, why the upper layer is so completely clear)
Http://www.wuleba.com/19035.html
Concrete Crack method no longer repeat, not the focus of this article, please resolve yourself.
Now, let's start to solve this seemingly large frame!
I have listed the class files (. cs) that need our attention in the project auto-generated files:
In the 1.app_start folder:
Startup.Auth.cs
In this file, there is only one Configureauth method, which is called in the Startup.cs of the root directory.
In this method, you can call (app. use/or other method name, seemingly using node's naming method, to load some "middleware (middleware)" required for authentication
Microsoft has given a number of examples, such as:
1. Configure the database context app. Createperowincontext (applicationdbcontext.create);
Use EntityFramework Code first to encapsulate database information and integrate with a large number of convenient data manipulation libraries
2. Initialize the User Manager and login Manager
App. Createperowincontext<applicationusermanager> (applicationusermanager.create);
App. Createperowincontext<applicationsigninmanager> (applicationsigninmanager.create);
Two createxxx inside the package of a lot of methods can be directly used to login, logout, registration, verification mailbox, etc., very convenient
You go to the controller to see in fact register login only need an await loginasync (...) /createasync (...) It's all right.
3. What else is the cookie login, remember my function, the outbound account login, etc., are packaged logical method
Every app. Use (...) In fact, there are a lot of logic behind the code, each use and only do one thing, fully embodies the powerful high-cohesion loose coupling framework characteristics!
IdentityConfig.cs
There are four of these classes:
The first two are SMS SMS and email service, not this chapter focus, slightly
The following two respectively are:
Applicationusermanager : usermanager<applicationuser>
Applicationsigninmanager : Signinmanager<applicationuser, string>
From the name can be seen as "User Manager" and "Login Manager", in fact, it is encapsulated the operation of the identity database method + Login Method
such as asynchronous login/Registration Loginasync (/*paras*/), Createasync (/*paras*/)
such as asynchronous Insert + Save data Insertasync (/*paras*/) SaveChanges (); Yes, some of the EF framework stuff.
The following article will decompile these two classes to see what the specific logic is and everyone will understand.
In the 2.Controllers folder:
AccountController.cs
Controller, detailed in the following article
In the 3.Models folder:
IdentityModels.cs
There are two of these classes:
applicationuser : Identityuser
applicationdbcontext : identitydbcontext<applicationuser>
The former represents the user table, which represents the identity database.
The one at the bottom of the root directory.
Startup.cs
There is only one configuration (Iappbuilder app) method
Use your own app parameters to invoke the Configureauth (app) in the Startup.Auth.cs file above;
With regard to the configuration method, it is simple to understand that "the main function is similar to the C language"
After the site is running, the framework helps us encapsulate the program's information into the app , then pass the app to the configuration and start the entire site.
We can look at what's inside this thing:
It is an instance object of a Appbuilder class that implements the Iappbuilder interface, which is basically a field of a dictionary class that looks like this after it is run:
You can see that some host information and "Other" unknown information, not the focus of this series, just click here.
To disassemble the ASP. MVC5 Identity System------(1)