Owin+asp.net Identity Analysis Series (III.) Frame structure analysis

Source: Internet
Author: User

Today, reading is sometimes a matter of "trouble". It takes time, energy, and a mind to pay. --Only with "Owin+asp.net Identity Analysis Series" to mourn the passing of ...

The first two blogs only say how the next function is implemented, this blog to analyze the role of Identitymodels, Identityconfig, Startup.auth class files in the Owin+asp.net identity framework

Identitymodels class files are stored in the user, role, database context, and other entity classes

The Identityconfig class file holds User Manager, Role Manager, database context Manager, and various services such as mail Service, SMS service, etc.

The Startup.auth class file holds configuration information for the entire membership framework

After probably knowing what these classes of files do, we can look at what the Microsoft Auto-generated code does. What do we need to do with ourselves?

1, first we look at the Identitymodels class file, this class contains ApplicationUser and Applicationdbcontext entity class

Note: See these two classes, we can guess, that maybe we can manage user information, as well as the management of database tables, because there is a database context

2, then look at the Identityconfig class file, this class contains Emailservice, SMSService, Applicationusermanager, Services and managers such as Applicationsigninmanager

Note: Through the class name has been very clear, Emailservice is to provide mail service, SMSService is to provide SMS service, Applicationusermanager (User Manager) to provide us with user management functions, Applicationsigninmanager (login Manager?) Call this name first) provide us with login information manager

3, finally, look at the startup class (a simple look at the creation of various managers and membership framework of some basic configuration)

Note: see here (chuckle), found that the previous definitions of the various managers have been put into the owincontext for management, and there are some basic configuration about user Login

4, after reading Identitymodels, Identityconfig and startup, on the remaining one, how do we get these Microsoft to provide us with a variety of cattle and cattle manager? With these managers, you can start a simple member login to register and manage these affiliate projects.

Protected Iauthenticationmanager AuthenticationManager {get {return Httpcontext.getowincontext (). authentication; }}protected Applicationusermanager Usermanager {get {return Httpcontext.getowincontext (). Getusermanager<applicationusermanager> (); } }

Note: Well, getting these managers is so simple!!! A member may have a member role, but we find that the auto-generated code does not have the relevant code for the role, so the role needs to be implemented by expanding the existing framework, so follow the next blog, "Implementing User Roles"

Owin+asp.net Identity Analysis Series (III.) Frame structure analysis

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.