我有共享托管提供的数据库。我想将会话存储在 sql server 中,但它给了我错误:
Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above
[HttpException (0x80004005): Unable to use SQL Server because ASP.NET version 2.0 Session State is not installed on the SQL server. Please install ASP.NET Session State SQL Server version 2.0 or above.]
System.Web.SessionState.SqlPartitionInfo.GetServerSupportOptions(SqlConnection sqlConnection) +2147087
System.Web.SessionState.SqlPartitionInfo.InitSqlInfo(SqlConnection sqlConnection) +107
System.Web.SessionState.SqlStateConnection..ctor(SqlPartitionInfo sqlPartitionInfo, TimeSpan retryInterval) +531
System.Web.SessionState.SqlSessionStateStore.GetConnection(String id, Boolean& usePooling) +237
System.Web.SessionState.SqlSessionStateStore.CreateUninitializedItem(HttpContext context, String id, Int32 timeout) +136
System.Web.SessionState.SessionStateModule.CreateUninitializedSessionState() +50
System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData) +659
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +96
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184
我的 WebConfig 包括以下语句。
<sessionState mode="SQLServer"
cookieless="true"
regenerateExpiredSessionId="true"
timeout="30"
allowCustomSqlDatabase="true"
sqlConnectionString="Data Source=hostingServer;Initial catalog=MyDatabase;User Id=MyUser;password=MyPassword;"
stateNetworkTimeout="60"/>
我跑了aspnet_regsql.exe
。创建后它询问我有关服务器和登录详细信息aspNret_TableNames
.
请指导我。
我相信您一定使用过 aspnet_regsql.exe 应用程序,它会启动一个向导,然后添加各种 aspnet_*桌子到你的桌子。
如果是这样,则再次重新启动同一向导,然后选择删除选项以从数据库中删除所有这些表。
现在运行这个命令:
aspnet_regsql.exe -ssadd -d <Your Database> -sstype c -S <Server> -U <Username> -P <Password>
然后,这会将两个表添加到您的数据库中,即 ASPStateTempApplications 和 ASPStateTempSessions。
修改您的 web.config 文件以包含以下配置:
<sessionState
mode="SQLServer"
allowCustomSqlDatabase="true"
sqlConnectionString="Data Source=Server;Initial Catalog=Database;User ID=UserId;Password=Password"
cookieless="false" timeout="20" />
笔记:
1. 我假设您希望将会话存储在应用程序数据库中。如果您想单独维护会话数据库,请运行上述命令而不带“-d”参数。这将创建一个新的 ASPState 数据库,其中包含我在上面指定的两个表。最后,您可以在配置中指定该数据库的名称。
希望这可以帮助 :)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)