授权属性问题

时间:2019-11-16 15:07:28

标签: c# asp.net-core asp.net-core-3.0

ConfigureServices

services.ConfigureApplicationCookie(
    options =>
    {
        options.LoginPath = "/Account/Login";
        options.LogoutPath = "/Account/Logout";
        options.AccessDeniedPath = "/AccessDenied";
    });

services
    .Configure<CookiePolicyOptions>(options =>
    {
        // This lambda determines whether user consent for non-essential cookies is needed for a given request.
        options.CheckConsentNeeded = context => true;
        options.MinimumSameSitePolicy = SameSiteMode.Lax;
        options.ConsentCookie.Name = ".AspNetCore.ConsentCookie";
    });

配置

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseAuthentication();
app.UseAuthorization();
app.UseRouting();
app.UseSession();

当我将[Authorize]放在任何控制器上时,即使我没有登录,无论页面加载什么,都可以。

0 个答案:

没有答案