1、配置web.config
<system.web>
<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data
source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="40"/>
</system.web>
2、在Global.asax中添加启动启动ASP.NET 状态服务代码
void Application_Start(object sender, EventArgs e)
{
// 在应用程序启动时运行的代码
try
{
//启动ASP.NET 状态服务
string g_serviceName = "aspnet_state";
System.ServiceProcess.ServiceController[] serviceControllers =
System.ServiceProcess.ServiceController.GetServices();
foreach (System.ServiceProcess.ServiceController service in serviceControllers)
{
if (service.ServiceName == g_serviceName)
{
if (service != null && service.Status != System.ServiceProcess.ServiceControllerStatus.Running)
{
service.Start();
SimpleLogHelper.WriteError(g_serviceName + "服务已开启");
}
else
{
if (service == null)
{
SimpleLogHelper.WriteError(g_serviceName + "服务未安装");
}
else
{
SimpleLogHelper.WriteError(g_serviceName + "服务正在运行...");
}
}
break;
}
}
}
catch (Exception ex)
{
SimpleLogHelper.WriteError(ex.ToString());
}
}
以上就是Asp.Net中Session失效是怎么解决的?的详细内容,更多请关注php中文网其它相关文章!
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。
程序员必备接口测试调试工具:点击使用
Apipost = Postman + Swagger + Mock + Jmeter
Api设计、调试、文档、自动化测试工具
网页生成APP,用做网站的技术去做APP:立即创建
手机网站开发APP、自助封装APP、200+原生模块、2000+映射JS接口按需打包
相关文章
相关视频