Here are three ways to achieve:
1.harbour.redissessionstatestore, Servicestack.redis
Configure Web. config
<sessionstateMode= "Custom"CustomProvider= "Redissessionstateprovider"> <providers> <Clear/> <Addname= "Redissessionstateprovider"type= "Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider"Host= "localhost:6379"ClientType= "Pooled" /> </providers> </sessionstate>
2.stackexchange.redis Redissessionstateprovider
configuration file Web. config
<sessionstateMode= "Custom"CustomProvider= "Mysessionstatestore"> <providers> <Addname= "Mysessionstatestore"type= "Microsoft.Web.Redis.RedisSessionStateProvider"Host= "127.0.0.1"Port= "6379"AccessKey=""SSL= "true" /> </providers> </sessionstate>
3. Custom Sessionstatestateprovider
<sessionstateMode= "Custom"CustomProvider= "Redissessionstateprovider"> <providers> <Clear/> <Addname= "Redissessionstateprovider"type= "Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider"Host= "localhost:6379"ClientType= "Pooled" /> </providers> </sessionstate>
I built an MVC project test, but created an action that didn't create the corresponding view, never added a value to the Redis, thought it was misconfigured, but I thought it was too simple, when I returned a view to complete a request, to know the session change, To make a corresponding change. Take care of it.
Redis Distributed session