标签:
这里有三种和方式实现:
1.Harbour.RedisSessionStateStore , ServiceStack.Redis
配置web.config
<sessionState mode="Custom" customProvider="RedisSessionStateProvider"> <providers> <clear /> <add name="RedisSessionStateProvider" type="Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider" host="localhost:6379" clientType="pooled" /> </providers> </sessionState>
2.StackExchange.Redis RedisSessionStateProvider
配置文件web.config
<sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="127.0.0.1" port="6379" accessKey="" ssl="true" /> </providers> </sessionState>
3.自定义SessionStateStateProvider
<sessionState mode="Custom" customProvider="RedisSessionStateProvider"> <providers> <clear /> <add name="RedisSessionStateProvider" type="Harbour.RedisSessionStateStore.RedisSessionStateStoreProvider" host="localhost:6379" clientType="pooled" /> </providers> </sessionState>
之前建了一个mvc的项目测试,但是创建了Action 没有创建对应的视图,一直不能再redis中增加值,以为自己配置错了,但是还是我想的太简单了,当返回一个view才完成一次请求,这样才能知道session的改变,才能做出相应的改变。注意下。
标签:
原文地址:http://www.cnblogs.com/nele/p/5491787.html