0

我有一个现有应用程序的问题,所以我创建了一个全新的 MVC 应用程序,除了读取会话状态之外没有其他功能,我也遇到了同样的问题。

使用 web.config 中的这一行:

<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="20" />

当应用程序运行并尝试使用会话时,我得到了这个:“无法向会话状态服务器发出会话状态请求。”

完整的错误堆栈和版本信息:

[HttpException (0x80070057): Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same.  If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection.  If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.]
System.Web.SessionState.OutOfProcSessionStateStore.MakeRequest(StateProtocolVerb verb, String id, StateProtocolExclusive exclusiveAccess, Int32 extraFlags, Int32 timeout, Int32 lockCookie, Byte[] buf, Int32 cb, Int32 networkTimeout, SessionNDMakeRequestResults& results) +3251784
System.Web.SessionState.OutOfProcSessionStateStore.DoGet(HttpContext context, String id, StateProtocolExclusive exclusiveAccess, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags) +169
System.Web.SessionState.OutOfProcSessionStateStore.GetItemExclusive(HttpContext context, String id, Boolean& locked, TimeSpan& lockAge, Object& lockId, SessionStateActions& actionFlags) +26
System.Web.SessionState.SessionStateModule.GetSessionStateItem() +111
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +778
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +254
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +48
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +159
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3160.0

我已经验证了 ASP.NET 状态服务正在运行,验证了注册表数据是否准确,验证了防火墙已完全关闭,因此本地端口不应该被阻止等等。我还能做些什么来验证与状态的连接服务器,可能会发生什么?

我试图重新安装 Framework 4.5,但它已经安装,所以它没有做任何事情。(该应用程序使用框架 4.5,顺便说一句)。
我尝试了使用 aspnet_regiis 的旧建议,但这显然不是更高版本的框架中的选项。我在这里和其他地方看到了几次被问到的问题,但是所有这些问题都通过我已经采取的步骤解决了,所以我不知道从这里去哪里。

感谢任何可以提供帮助的人!

(编辑/补充:我还在注册表中将 AllowRemoteConnection 设置为 1。我验证了该服务似乎正在监听:

C:\WINDOWS\system32>netstat -aon | find /i "42424"
  TCP    0.0.0.0:42424          0.0.0.0:0              LISTENING       4256
4

0 回答 0