微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ASP.NET标识会话超时

我使用ASP.NET身份..我想将会话超时设置为无限或最大值.我尝试了一些东西,但它没有效果.注意:我使用共享主机.
谢谢.
//web.config
<system.web>
<customErrors mode="Off" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms" />
<sessionState timeout="500000" />
</system.web>

//asp.identiyt config 
public void ConfigureAuth(IAppBuilder app)
{
    app.UseCookieAuthentication(new CookieAuthenticationoptions
    {
        AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,ExpireTimeSpan = TimeSpan.FromDays(365),LoginPath = new PathString("/user/login"),Provider = new CookieAuthenticationProvider
        {
            OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager,ApplicationUser,int>
                (
                     validateInterval: TimeSpan.FromDays(365),regenerateIdentityCallback: (manager,user) => user.GenerateUserIdentityAsync(manager),getUserIdCallback: (id) => (Int32.Parse(id.GetUserId()))
                )
        }
    });
}

解决方法

public void ConfigureAuth(IAppBuilder app)
{            
    var sessionTimeout = 20; // 

    app.UseCookieAuthentication(new CookieAuthenticationoptions
    {
        ExpireTimeSpan = TimeSpan.FromSeconds(30),});
}

原文地址:https://www.jb51.cc/aspnet/251081.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐