Asp.net 会话状态服务器与 SQL Server

发布于 2024-08-12 17:24:46 字数 644 浏览 1 评论 0原文

我们尝试使用以下 web.config 行使会话状态正常工作:

<sessionState 
    mode="SQLServer" 
    stateConnectionString="tcpip=127.0.0.1:42424" 
    sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password='thepassword'" 
    cookieless="false" 
    timeout="20"/>

在 dbServer 上,我们运行以下命令来设置 ASPState db:

aspnet_regsql.exe -S localhost-E -ssadd -sstype p

在 webServer 上,我们启动了 ASP.Net 状态服务,但是,表 ASPStateTempApplications 或 ASPStateTempSessions 中没有显示任何记录,并且看起来非常像会话仍然存储在进程中。

怎么了?状态服务是否应该在数据库服务器上运行?它是否与 IIS 一起安装,因为尽管安装了 .net 3.5.1,但它在该计算机上不可用。

IIS 日志没有显示任何失败提示。怎么了?

We're trying to get session state working using the following web.config line:

<sessionState 
    mode="SQLServer" 
    stateConnectionString="tcpip=127.0.0.1:42424" 
    sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password='thepassword'" 
    cookieless="false" 
    timeout="20"/>

On dbServer, we've run the following command to set up the ASPState db:

aspnet_regsql.exe -S localhost-E -ssadd -sstype p

On the webServer, we've started the ASP.Net state service, however, no records show up in tables ASPStateTempApplications or ASPStateTempSessions, and it seems very much like session is still being stored in process.

What's wrong? Should the state service be running on the DB server? Does it get installed with IIS, because it's not available on that machine, despite .net 3.5.1 being installed.

The IIS logs show no hint of failure. What's wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

弥繁 2024-08-19 17:24:46

如果密码确实有引号,请尝试删除它们:

sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password=thepassword"

并删除以下行,它没有 SQL 会话存储功能:

stateConnectionString="tcpip=127.0.0.1:42424" 

And you might as well stop the state service;它是进程外会话状态所需要的,而不是 SQL Server 会话状态所需要的。

此外,SQL Server 会话状态要求您在数据库上运行 InstallSqlState.sql,而不是 aspnet_regsql.exe。它应该创建一个新的 ASPState 数据库。

If there's really quotes around the password, try to remove them:

sqlConnectionString="Data Source=dbServer;User ID=stateUser;Password=thepassword"

And remove the following line, it has no function for SQL session storage:

stateConnectionString="tcpip=127.0.0.1:42424" 

And you might as well stop the state service; it's needed for out-of-process session state, not for SQL Server session state.

Also, SQL Server session state requires you to run InstallSqlState.sql on the database, not aspnet_regsql.exe. It should create a new ASPState database.

攒一口袋星星 2024-08-19 17:24:46

首先,您不需要启动状态服务即可使用 SQL Server 会话状态。忘掉 ASP.NET 状态服务吧。

您确定您的站点正在创建会话变量吗?仅仅因为您将这些更改放入 web.config 中,如果您从不使用会话变量,则不会使用它。

First, you don't need to start the State Service in order to use SQL Server session state. Forget about the ASP.NET State Service.

Are you sure that your site is creating a session variable? Just because you put these changes in your web.config, if you never use session variables, it won't be used.

恍梦境° 2024-08-19 17:24:46

写一个小的 HttpModule 怎么样?当您需要将用户转换到新的代码库时,您可以将其放在适当的位置。该模块可以对每个页面请求做一些工作来检查用户的会话并决定是否需要放弃它。也许您在首次创建会话时将应用程序版本字符串存储在用户会话中,并将当前应用程序版本字符串与该字符串进行比较。

How about writing a small HttpModule? You could drop it into place for the period of time when you need to transition users to the new codebase. The module could do some work on each page request to check the user's session and decide whether it needs to be abandoned. Perhaps you store an application version string in the user's session when the session is first created and compare the current app version string against that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文