Can we have Multiple RedisSessionStateProvider

Sushanth Kumar Jayanthi 0 Reputation points
2023-09-11T18:41:50.6866667+00:00

Hello,

We are migrating our redis instance from V4 to V6 , after the migration we want to switch the provider from old to new. Is there any way where i can dynamically swich between the rovider based in a flag ?

https://www.nuget.org/packages/Microsoft.Web.RedisSessionStateProvider/

Ex:

 <sessionState      mode="Custom"      cookieless="UseCookies"      regenerateExpiredSessionId="true"      timeout="245"      cookieName="DESKTOPSESSION"      cookieSameSite="None"      customProvider="Dmc.WebService.CustomSessionStateProvider">      

<providers>         

<add name="RedisNew" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionStringNew="redisnew.redis.cache.windows.net:6380,password=fafafvdf=,ssl=True,sslProtocols=Tls12,abortConnect=False" throwOnError="false" operationTimeoutInMilliseconds="5000" retryTimeoutInMilliseconds="8000" connectionTimeoutInMilliseconds="10000" />

<add name="RedisOld" type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="redisold.redis.cache.windows.net:6380,password=fdfafggegge=,ssl=True,sslProtocols=Tls12,abortConnect=False" throwOnError="false" operationTimeoutInMilliseconds="5000" retryTimeoutInMilliseconds="8000" connectionTimeoutInMilliseconds="10000" />     
 </providers>   

 </sessionState>

Based on a flag we want to swich from old to new at runtime without restartign the app

Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
260 questions
{count} votes

1 answer

Sort by: Most helpful
  1. GeethaThatipatri-MSFT 29,477 Reputation points Microsoft Employee
    2023-09-11T19:46:56.4766667+00:00

    Hi,@Sushanth Kumar Jayanthi Thanks for posting your question in the Microsoft Q&A forum.

    If I understand correctly you want to know if it is possible to dynamically switch between two RedisSessionStateProvider instances based on a flag without restarting the app.

    The session state provider cannot be changed dynamically. However, you can find a way as mentioned here

    You check the similar ask in the SO forum here

    On your second question, you might be able to use reflection to achieve the desired outcome.

    Regards

    Geetha

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.