C
C#3y ago
Eple

Web Application with separate protected areas

I want to build a web app. All pages should require login. There should be a special area /admin where an Admin can login, and they should be able to create User for the main app. I need help to get started. I've created project from template and nothing more.
3 Replies
Angius
Angius3y ago
You can use a feature meant pretty much exactly for that And with pretty much the exact name "Areas" You can then set different authorization policies per area, like requiring a user to have a role Admin
Eple
EpleOP3y ago
Thank you. I have now the following.
builder.Services.AddRazorPages(options =>
{
options.Conventions.AuthorizeAreaFolder("Admin", "/", "IsAdmin");
});

builder.Services.AddAuthorization(options =>
{
options.AddPolicy("IsAdmin", policy => policy.RequireRole("Admin"));
});
builder.Services.AddRazorPages(options =>
{
options.Conventions.AuthorizeAreaFolder("Admin", "/", "IsAdmin");
});

builder.Services.AddAuthorization(options =>
{
options.AddPolicy("IsAdmin", policy => policy.RequireRole("Admin"));
});
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server