How to change sqlConnectionString for sessionState in SQLServer mode at runtime?

We are trying to find a way to change sessionState sqlConnectionString (in SQLServer mode) at run time. We are introducing a failure for our SQL server, and we want to catch when sessionState cannot access my SQL server and tell it to stop working on my secondary server and at the same time initialize the crawl of the site as a whole.

If I do not understand, feel free to ask me more. (By the way, we use C #)

Change To be sure I'm talking about sessionState, not regular connections to the sql server, see http://msdn.microsoft.com/en-us/library/h6bb9cz9(vs.71).aspx .

My current web.config is constructed as follows:

<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.

+4
source share
2 answers

Depending on how you manage your connection, you can specify mirrored server failure partners in the connection string to the SQL server:

 Data Source=myServerAddress; Failover Partner=myMirrorServerAddress; Initial Catalog=myDataBase; Integrated Security=True; 

(from here )

+1
source

Based on what I'm reading [here] , you can create partitionResolverType to give you control over the connection of the string at runtime. I have not tested it, but I'm currently looking for the same control over the connection string, and it looks like this might do the trick.

0
source

All Articles