Amr*_*ngh 2 asp.net session-state sql-server-2008
我有共享主机提供的数据库.我想在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
Run Code Online (Sandbox Code Playgroud)
我的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"/>
Run Code Online (Sandbox Code Playgroud)
我已经运行aspnet_regsql.exe.它问了我创建后的服务器和登录详细信息aspNret_TableNames.
请指导我.
Shr*_*oid 13
我相信您必须使用aspnet_regsql.exe应用程序,然后启动向导,然后向表中添加各种aspnet_ *表.
如果是,则再次重新启动同一向导,然后选择remove选项以从数据库中删除所有这些表.
现在运行此命令:
aspnet_regsql.exe -ssadd -d <Your Database> -sstype c -S <Server> -U <Username> -P <Password>
Run Code Online (Sandbox Code Playgroud)
然后,这将向您的数据库添加两个表,即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" />
Run Code Online (Sandbox Code Playgroud)
注意:1.我假设您要在应用程序数据库中存储会话.如果要单独维护会话数据库,请运行上面的命令而不使用"-d"参数.这将创建一个新的ASPState数据库,其中包含两个我在上面指定的表.最后,您可以在配置中指定此数据库的名称.
希望这可以帮助 :)
| 归档时间: |
|
| 查看次数: |
11202 次 |
| 最近记录: |