4

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.

Sébastien Richer
  • 1,642
  • 2
  • 17
  • 38
  • Solution was to use a PartitionResolver : System.Web.IPartitionResolver with a public method public string ResolvePartition(object key) that will return the appropriate connection string. – Sébastien Richer Nov 22 '10 at 15:50

2 Answers2

1

Depending on how you're managing your connection, you can specify a mirrored server's failover partners in a SQL server connection string:

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

(from here)

Beth
  • 9,531
  • 1
  • 24
  • 43
Ed Harper
  • 21,127
  • 4
  • 54
  • 80
0

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.

Nikolay Kostov
  • 16,433
  • 23
  • 85
  • 123