i am using RedisSessionStateProvider with asp.net mvc 4.5 for session management. i am using azure web app for my hosting. how do i override this connection info on azure portal during prod deployment. is there any other way than using web.release.config transform file?
<sessionState mode="Custom" timeout="2000" customProvider="MySessionStateStore">
<providers>
<add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="server.cloudapp.net" port="6379" accessKey="password" ssl="false" databaseId="1" applicationName="pWeb" />
</providers>
</sessionState>
The provider takes in a ConnectionString parameter which can point to an appsetting. You can set this appsetting based on the environment you are running in. The following code shows the web.config
<appSettings>
<add key="RedisConnection" value="cachename.redis.cache.windows.net,ssl=true,password=password"/>
</appSettings>
<sessionState mode="Custom" customProvider="MySessionStateStore">
<providers>
<add name="MySessionStateStore"
type="Microsoft.Web.Redis.RedisSessionStateProvider" connectionString="RedisConnection"/>
</providers>
</sessionState>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With