builder.Services.AddAuthentication(option => { option.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme; }).AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, option => { option.LoginPath = "/Login/Index";//沒登入跳到登入頁 option.AccessDeniedPath = "/Login/NoAuthority"; //登入了沒許可權 });