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

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale 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 的服务端口一致