ASP.NET标识会话超时
发布时间:2020-05-23 23:21:07 所属栏目:asp.Net 来源:互联网
导读:我使用ASP.NET身份..我想将会话超时设置为无限或最大值.我尝试了一些东西,但它没有效果.注意:我使用共享主机. 谢谢. //web.configsystem.webcustomErrors mode=Off /httpRuntime targetFramework=4.5 /authentication mode=Forms /sessionState
|
我使用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),});
} (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – 什么是AsyncManager.OutstandingOperations
- asp.net-mvc – ASP.NET Azure 400错误请求不返回JSON数据
- asp.net-mvc – 具有错误的剃刀语法编译时不应该编译
- 从客户端调用asp.net ajax服务器控件的公共函数
- asp.net – IIS 7在一个服务器上引发web.config的“重复部分
- ASP.NET MVC:将自定义属性放入选择列表中的选项标签
- asp.net – 在项目之间共享aspx页面
- asp.net – 这些Web Essentials选项有什么作用?
- ASP.NET MVC与Facebook Connect模板项目
- asp.net – 确定所需服务器数量的最佳方法
推荐文章
站长推荐
- asp.net-mvc – ASP.NET MVC Master Detail Entr
- asp.net-mvc-3 – 从自定义授权属性访问角色
- asp.net-mvc – 如何在一个视图中使用两个IENume
- ASP.NET %=% vs %:%
- asp.net-mvc-3 – ASP.NET MVC 3.0 Razor,从任何
- asp.net-mvc – 如何在ASP.NET MVC路由中使用带有
- asp.net-mvc – 如何使用Visual Studio 2013和En
- 一个IIS WebSite可以托管不同ASP.NET版本的多个W
- asp.net核心 – Microsoft Asp.Net 5 RC1
- asp.net-mvc – Asp.Net MVC 2 – 更改PropertyV
热点阅读
