在MVC中配置鑑權

龙卷风吹毁停车场發表於2024-08-08
builder.Services.AddAuthentication(option =>
{
    option.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, option =>
{
    option.LoginPath = "/Login/Index";//沒登入跳到登入頁
    option.AccessDeniedPath = "/Login/NoAuthority"; //登入了沒許可權
});

相關文章