执行appcmd命令后Cookie模式会话状态未更新,IIS7.5求助
I’ve dealt with this exact frustrating issue on IIS 7.5/Server 2008 R2 before—your appcmd command says it worked, but the session timeout never actually updates. Let’s walk through the most common fixes and checks:
1. Check for Local web.config Overrides
The appcmd command you ran applies settings at the server/web root level, but if your site’s own web.config file has a <sessionState> node, it will override the server-level config every time.
- Head to your site’s root directory, open
web.configin a text editor. - Look for the
<system.web><sessionState>section. If it exists, update thetimeoutattribute to520directly here. If you want to inherit the server setting instead, delete this section entirely.
2. Fix Application Pool Recycling Interference
Even if your session timeout is set correctly, application pool recycling will kill all active sessions early, making it look like your setting isn’t working.
- Open IIS Manager, expand the Application Pools node, find the pool tied to your site.
- Right-click the pool → Advanced Settings.
- Under the Recycling section:
- Set Fixed Interval (minutes) to a value greater than 520 (like 540, or set to 0 to disable fixed-time recycling).
- Check Virtual Memory Limit and Private Memory Limit—if these thresholds are hit, the pool will recycle unexpectedly. Increase these values or set to 0 to disable memory-based recycling if it’s unnecessary.
3. Don’t Forget to Restart the App Pool/Site
Configuration changes rarely take effect immediately. After running appcmd or editing web.config, right-click your site or application pool and select Restart.
4. Adjust the appcmd Command Target
Your original command is close, but try targeting the site’s specific configuration path directly with this tweak:
C:\Windows\system32\inetsrv\APPCMD set config "site_name" /section:sessionState /timeout:520 /commit:APPHOST
Using /commit:APPHOST ensures the change applies at the site level rather than the web root, which can fix inheritance quirks.
5. Verify .NET Framework Version Alignment
Mismatched .NET versions between your application pool and site can cause config settings to be ignored:
- In IIS Manager, right-click your application pool → Basic Settings.
- Confirm the .NET Framework version matches what your site is built on (e.g., v2.0 or v4.0).
If none of these work, check the IIS logs and Event Viewer for errors related to session state or config processing—they’ll often reveal hidden issues blocking the setting from sticking.
内容的提问来源于stack exchange,提问作者mohan08p

