|
|

缺点:
仅限于.net的网站,所有站点都是.net做的网站,和其他语言混合的话,原理上是可以的,但是,我没有做过。
第一步:
引用StackExchange.Redis
- PM> Install-Package StackExchange.Redis
复制代码
https://github.com/StackExchange/StackExchange.Redis
第二步:
引用Microsoft.Web.Redis.RedisSessionStateProvider
- Install-Package Microsoft.Web.RedisSessionStateProvider
复制代码
第三步:
配置web.config
- <system.web>
- <sessionState mode="Custom" customProvider="MySessionStateStore" cookieName="__test_id__">
- <providers>
- <!-- For more details check https://github.com/Azure/aspnet-redis-providers/wiki -->
- <!-- Either use 'connectionString' OR 'settingsClassName' and 'settingsMethodName' OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. -->
- <!-- 'throwOnError','retryTimeoutInMilliseconds','databaseId' and 'applicationName' can be used with both options. -->
- <!--
- <add name="MySessionStateStore"
- host = "127.0.0.1" [String]
- port = "" [number]
- accessKey = "" [String]
- ssl = "false" [true|false]
- throwOnError = "true" [true|false]
- retryTimeoutInMilliseconds = "5000" [number]
- databaseId = "0" [number]
- applicationName = "" [String]
- connectionTimeoutInMilliseconds = "5000" [number]
- operationTimeoutInMilliseconds = "1000" [number]
- connectionString = "<Valid StackExchange.Redis connection string>" [String]
- settingsClassName = "<Assembly qualified class name that contains settings method specified below. Which basically return 'connectionString' value>" [String]
- settingsMethodName = "<Settings method should be defined in settingsClass. It should be public, static, does not take any parameters and should have a return type of 'String', which is basically 'connectionString' value.>" [String]
- loggingClassName = "<Assembly qualified class name that contains logging method specified below>" [String]
- loggingMethodName = "<Logging method should be defined in loggingClass. It should be public, static, does not take any parameters and should have a return type of System.IO.TextWriter.>" [String]
- />
- -->
- <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="127.0.0.1" port="11511" accessKey="pass123" ssl="false" />
- <!--<add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="" accessKey="" ssl="true" />-->
- </providers>
- </sessionState>
- <compilation debug="true" targetFramework="4.0" />
- <pages>
- <namespaces>
- <add namespace="System.Web.Helpers" />
- <add namespace="System.Web.Mvc" />
- <add namespace="System.Web.Mvc.Ajax" />
- <add namespace="System.Web.Mvc.Html" />
- <add namespace="System.Web.Routing" />
- <add namespace="System.Web.WebPages" />
- </namespaces>
- </pages>
- </system.web>
复制代码
|
上一篇:[StackExchange.Redis.ServerEndPoint]' violates the constraint of type paramet...下一篇:不借助第三方实现AndroidPush消息推送服务
|