Identity add Management in ASP.NET5 MVC templates (Roles and user additions)

Source: Internet
Author: User
Tags app service

First of all, I would like to recommend several articles found in these days:

1.Create an ASP. NET MVC app with Auth and SQL DB and deploy to Azure app Service

The knowledge I get from this article is primarily about how roles are added.

The first thing I learned was the role of the feature [authorize]: primarily restricting the role to access the method, such as adding the [Authorize (role= "admin")] attribute on index (), only the user of the Admin role can access it.

So I was thinking, if my own site requires three levels of user (myself, admin, normal user) How do I add these three characters?

I look for, finally found a feasible way, is to use the NuGet console to install a entityframework database update operation, as long as the console input enable-migration can be installed automatically, A migration folder appears in the project with a configuration CS file.

Then, you can do the same thing as the middle section of the article to implement the role of adding and user binding specific roles.

It's just a way of adding a role, and updating the database tables with these code is the entityframework of the code-first pattern.

2.Customizing profile information in ASP. NET Identity in VS. templates

This article let me know is that I change the identity generated by the user table, you can change the User table field, you do not have to find a way to configure a lot of account issues, I was thinking that I built an account management, but also think about, Anyway, MVC provides identity2.0, why do you have to build an account management, and do not necessarily safe, or first use the identity bar, until feel really unable to solve their own problems to find a way.

Actually adding the Identity User table field is very simple, just need to add an attribute in the ApplicationUser class in IdentityModel, and write the model is a meaning, Then use the migration (Migration Tool) to update the database is OK

Update-database

Identity add Management in ASP.NET5 MVC templates (Roles and user additions)

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.