i want to know asp.net authorize function can it be used in .net core?
Or something can instead in authorize for .net core? thanks
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
You can use Microsoft.AspNetCore.Identity with Identity Server 4 to authorize your application.
The tutorial from MS is Here.
In short, you can change Authentication to Individual User Accounts when create new projects. Or you can scaffold Identity into an exist project
For example, you can scaffold Identity into an empty project:
- From Solution Explorer, right-click on the project > Add > New Scaffolded Item.
- From the left pane of the Add New Scaffolded Item dialog, select Identity > Add.
- In the
Add Identitydialog, select the options you want.
- Select your existing layout page, or your layout file will be overwritten with incorrect markup:
~/Pages/Shared/_Layout.cshtmlfor Razor Pages~/Views/Shared/_Layout.cshtmlfor MVC projects- Blazor Server apps created from the Blazor Server template (
blazorserver) aren’t configured for Razor Pages or MVC by default. Leave the layout page entry blank.- Select the + button to create a new Data context class. Accept the default value or specify a class (for example,
MyApplication.Data.ApplicationDbContext).- Select Add.
Then generate Identity database schema:
Install-Package Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore
Add-Migration CreateIdentitySchema
Update-Database
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0