It's hard to write software in a software company, no time. So it's probably going to be slow and slow to make what I want. Take it slow.
Microsoft offers a quick set-up for user registration, although it may seem complicated, but easy to use.
Here just want to do a simple backstage, have the basic authority management, and have a simple table of additions and deletions to check the example.
The source code has been uploaded to Github,https://github.com/wuyt/rckohi
Install the vs2017 and. NET core environments first.
New Project
Select ASP.net Core Web application
Select the version, MVC Web application, and change the authentication.
There is no web application here, in fact, it is no use of razor + MVC pattern. The pattern of Web apps seems to be good, but Microsoft itself doesn't have the ability to do it in VS, and it relies on plug-ins and command lines to add it, and it makes people feel that Microsoft is not confident. So, it's time to wait for this feature to be considered later.
Select a personal user account to store the user account in the application
After you have modified it, click OK
At this time, VS will automatically generate a project with user registration and login
Open Startup.cs, and in the Configureservices method, add content
Add the code below to the inside,
Services. Configure<identityoptions> (Options => {//Password settings options.)
Password.requiredigit = false; Options.
Password.requiredlength = 6; Options.
Password.requirenonalphanumeric = false; Options.
Password.requireuppercase = false; Options.
Password.requirelowercase = false; Options.
Password.requireduniquechars = 6; Lockout settings options.
Lockout.defaultlockouttimespan = Timespan.fromminutes (30); Options.
lockout.maxfailedaccessattempts = 5; Options.
Lockout.allowedfornewusers = false; User settings Options.
User.requireuniqueemail = false;
}); Services. Configureapplicationcookie (Options => {//Cookie settings options.)
Cookie.httponly = true; Options.Cookie.expiration = Timespan.fromdays (150); Options. Loginpath = "/account/login"; If The Loginpath is isn't set here, asp.net Core would default to/account/login options. Logoutpath = "/account/logout"; If The Logoutpath is isn't set here, asp.net Core would default to/account/logout options. Accessdeniedpath = "/account/accessdenied"; If The Accessdeniedpath is isn't set here, asp.net Core would default to/account/accessdenied options.
SlidingExpiration = true;
});
The above code is to configure login information, you can participate in the official Microsoft Tutorial: https://docs.microsoft.com/zh-cn/aspnet/core/security/authentication/ Identity-configuration?tabs=aspnetcore2x
Open the Appsettings.json and set the next database connection. Here I simply changed the database name.
Click the Debug Run
Wait a moment, you can see the page.
Click on the top right corner of the registration
This time will jump to the registration page, fill out the content click the registration button.
At this point, the page will look like this because the database content for the login is not yet a table structure. Click on the blue button
After you see the prompts to refresh the page, refresh the next page.
This time, on the right, will automatically log in, click on the mailbox can see the user's information.