asp.net核心Cookie身份验证滑动过期无效

时间:2018-11-29 07:31:45

标签: authentication cookies

我已经在asp.net core 2应用程序中配置了cookie身份验证, 这是启动文件中的配置文件

 //1:
        services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
        .AddCookie(CookieAuthenticationDefaults.AuthenticationScheme,
        options =>
        {
            //REF:https://tahirnaushad.com/2017/09/08/asp-net-core-2-0-cookie-authentication/
            //Cookie Authentication Options

            //Login View
            options.LoginPath = "/Account/Login";
            //Logout Action
            options.LogoutPath = "/Account/Logout";
            //Controls how much time the cookie will remain valid from the point it is created. 
            options.SlidingExpiration = true;
            //Ticket Expiration :represents the expiration of the ticket NOT the cookie that contains the ticket.
            //an expired cookie will be ignored even if it is passed to the server after the browser should have purged it.
            options.ExpireTimeSpan = TimeSpan.FromMinutes(10);
            //Cookie Expiration
            options.Cookie.Expiration = TimeSpan.FromMinutes(10);
            //override default name of cookie, which is .AspNetCore.Cookies
            options.Cookie.Name = "HDAPP1.0";
            //cookie can be accessed from client side scripts
            options.Cookie.HttpOnly = false;


            //ReturnUrlParameter = "returnUrl"
        });

        //2:
        services.AddAuthentication(options =>
        {
            options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
        });

        //3:add app.UseAuthentication(); in Configure Method

问题在于,无论您是否在网站上进行工作,滑动到期都不起作用,并且应用程序总是在10分钟内退出。

0 个答案:

没有答案
相关问题