如何在运行时更改SQLServer模式下sessionState的sqlConnectionString?
我们正在尝试找到一种在运行时更改 sessionState 的 sqlConnectionString (在 SQLServer 模式下)的方法。我们正在为 SQL 服务器实现故障转移,我们希望捕获 sessionState 无法访问我的 SQL 服务器的情况,并告诉它故障转移到我的辅助服务器并同时初始化站点范围的故障转移。
如果我不清楚,请随时询问我更多详细信息。 (顺便说一句,我们使用的是 C#)
编辑:为了确定,我说的是 sessionState,而不是常规的 sql 服务器连接,请参阅 http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx。
我当前的 web.config 是这样构建的:
<configuration>
[...]
<system.web>
[...]
<sessionState mode="SQLServer" timeout="525600" sqlConnectionString="Data Source=localhost\SQLEXPRESS;User ID=myUser;password=myPassword" cookieless="false"/>
</system.web>
[...]
</configuration>
希望这有帮助。
We're trying to find a way to change the sessionState's sqlConnectionString (in SQLServer mode) at runtime. We're implementing a fail over for our SQL server and we want to catch when the sessionState fails to have access to my SQL server and tell it to fail over to my secondary server and initialize the site-wide fail over at the same time.
If I'm not clear please feel free to ask me more details. (BTW we're using C#)
Edit: Just to be sure, I'm talking about sessionState and not regular sql server connections see http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx.
My current web.config is built like this :
<configuration>
[...]
<system.web>
[...]
<sessionState mode="SQLServer" timeout="525600" sqlConnectionString="Data Source=localhost\SQLEXPRESS;User ID=myUser;password=myPassword" cookieless="false"/>
</system.web>
[...]
</configuration>
Hope this helps.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您管理连接的方式,您可以在 SQL Server 连接字符串中指定镜像服务器的故障转移伙伴:(
来自 此处)
Depending on how you're managing your connection, you can specify a mirrored server's failover partners in a SQL server connection string:
(from here)
根据我正在阅读的内容 [在这里]您可以创建一个
partitionResolverType
来让您在运行时控制连接字符串。我还没有验证它,但我目前正在寻找对连接字符串的相同控制,这看起来可能可以解决问题。Based on what I am reading [here] you could create a
partitionResolverType
to give you control over the connection string at runtime. I have not verified it, but I am currently looking for the same control over the connection string and this looks like it may do the trick.