I wish to change the session state provider dynamically when a web page loads.
Locally, while developing, we use the following:
<sessionState mode="InProc" />
But production code runs like this:
<sessionState mode="Custom" customProvider="CustomSessionStateProvider">
<providers>
<add name="CustomSessionStateProvider" type="Library.CustomSessionStateProvider" applicationName="AppName" />
</providers>
</sessionState>
Is it not possible to change which provider the sessionState uses at runtime before a page loads? It would be determined by some kind of configurable item:
if(Environmental.IsProduction)
{
// Use custom provider
}
else
{
// Use InProc
}
We do use different config files per environment, but this feature needs to be available in all environments.