惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Forbes - Security
Forbes - Security
GbyAI
GbyAI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
SegmentFault 最新的问题
Y
Y Combinator Blog
Recorded Future
Recorded Future
博客园 - Franky
I
InfoQ
T
The Blog of Author Tim Ferriss
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
阮一峰的网络日志
阮一峰的网络日志
T
Tailwind CSS Blog
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
雷峰网
雷峰网
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Cloudbric
Cloudbric
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
MongoDB | Blog
MongoDB | Blog
F
Full Disclosure
Google DeepMind News
Google DeepMind News
Recent Commits to openclaw:main
Recent Commits to openclaw:main
C
Check Point Blog
爱范儿
爱范儿
The GitHub Blog
The GitHub Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
T
Threat Research - Cisco Blogs
U
Unit 42
N
Netflix TechBlog - Medium
The Cloudflare Blog
Spread Privacy
Spread Privacy
Microsoft Azure Blog
Microsoft Azure Blog
美团技术团队
T
Troy Hunt's Blog
Engineering at Meta
Engineering at Meta
H
Heimdal Security Blog
TaoSecurity Blog
TaoSecurity Blog
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
B
Blog
S
Securelist
H
Hacker News: Front Page
Google Online Security Blog
Google Online Security Blog
G
Google Developers Blog

博客园 - heart-in-sky

查询效率分析 svn权限 为IIS服务器添加扩展 oracle 查询历史语句 VS自带混乱器 AjaxPro组件实现前后台数据无刷新交互 - heart-in-sky - 博客园 VSS管理 oracle管理 C#操作服务器文件 服务器操作 iis发布网站,域名指向 关于软件开发和模块接口设计之一些思考 oracle数据库同步 WCF双工 Oracle常用的数据库字段类型 vs快捷键 对象数组与DataTable互换 C#网络编程 系统库设计说明书(数据库字典)
使用 StateServer 持久保存 Session 会话状态 !
heart-in-sky · 2010-06-28 · via 博客园 - heart-in-sky

ASP.NET 使用mode=”InProc”方式保存Session老是丢失,无奈改成StateServer 模式

session是工作在你的应用程序进程中的。asp.net进程、iis往往会在20分钟之后重启相关的应用程序,缓冲池满了(例如100个之后)也会重启,各种进程保护措施都会随时重新启动,因此InProc方式丢失session是很正常的事。csdn上明确告诉了这种模式只能保存“易失的、暂时的 ”变量,这是cache没有之前的一种解决方案。而长期保持的数据就要保存在外部数据源中。状态服务器就是一种进程外的数据源。

StateServer 模式的实质是,把Session 存放在一个单独的进程里,此进程独立于 aspnet_wp.exe 或 w3wp.exe 。启用此服务后,在“任务管理器”中可以看到一个名为 aspnet_state.exe 的进程,下面开始说明一下设置的具体步骤:

1、 修改注册表(关键步骤,如下图)

运行 regedit → 打开注册表 → 找到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state \Parameters 节点 → 将 AllowRemoteConnection 的键值设置成“1”(1 为允许远程电脑的连接,0 代表禁止)→ 设置 Port (端口号)

注意事项:

a)、若ASP.NET State Service 正在运行,修改注册表内容后,则需要重新启动该服务

b)、注意端口号的键值是以十六进制储存的,可以使用十进制进行修改,42424 是默认的端口

c)、AllowRemoteConnection 的键值设置成“1”后,意味着允许远程电脑的连接,也就是说只要知道你的服务端口,就可享用你的ASP.NET State Service,即把 Session 存放在你的电脑进程内,因此请大家慎用;键值为“0”时,仅有stateConnectionString 为“tcpip=localhost: 42424”与“tcpip=127.0.0.1:42424”的情况,方可使用ASP.NET State Service

2、 开启 ASP.NET State Service

右键点击“我的电脑”→ 管理 → 服务与应用程序 → 服务 → 双击“ASP.NET State Service” → 启动(可设为“自动”)

说明:只要安装了 .Net Framework ,都拥有此服务。

3、 更改 Web.config

打开 Web.config → 找到 <sessionState> 节点内容

<sessionState

mode=”InProc”

stateConnectionString=”tcpip=127.0.0.1:42424″

sqlConnectionString=”data source=127.0.0.1;Trusted_Connection=yes”

cookieless=”false”

timeout=”20″ />

→ 将其改为以下内容

<sessionState mode=”StateServer” stateConnectionString=”tcpip=192.168.0.2:42424″ timeout=”20″ />

注意事项:

1、timeout=”20″为Session 20分钟超时

2、IP 地址(可以是远程计算机 IP、计算机名称、域名)与端口号,端口号需与ASP.NET State Service 的服务端口一致