我正在尝试将asp.net会话状态存储在缓存(用于redis的azure缓存)中,如这里所述https://docs.microsoft.com/en-us/azure/azure-cache-for-redis/cache-aspnet-session-state-provider
但是,我收到下面的错误。
无法连接mydomain.redis.cache.windows。net:6379/interactive,来源:resetnonconnected,输入缓冲区:0,未完成:0,上次读取:5s前,上次写入:5s前,未应答写入:1106595s前,保持活动状态:60s,挂起:0,状态:正在连接,上次心跳:从不,上次mbeat:-1s前,全局:5s前,管理器:不活动,错误:never stackexchange.redis.redisconnectionexception:unabletoconnect on mydomain.redis.cache.windows。net:6379/interactive,来源:resetnonconnected,输入缓冲区:0,未完成:0,上次读取:5s前,上次写入:5s前,未应答写入:1106595s前,保持活动:60s,挂起:0,状态:正在连接,上次心跳:从不,上次mbeat:-1s前,全局:5秒前,经理:不活动,错误:从不
<add name="AzureRedisCacheConnection" connectionString="mydomain.redis.cache.windows.net:6379,password=password=,ssl=False,abortConnect=False"/>
</connectionStrings>
<sessionState mode="Custom" customProvider="AzureCacheForRedisProvider">
<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="AzureCacheForRedisProvider"
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]
redisSerializerType = "<Assembly qualified class name that implements Microsoft.Web.Redis.ISerializer>" [String]
/>
-->
<add name="AzureCacheForRedisProvider" type="Microsoft.Web.Redis.RedisSessionStateProvider"
connectionString="AzureRedisCacheConnection"
/>
</providers>
</sessionState> ````
What am I missing here?
1条答案
按热度按时间n1bvdmb61#
我读过官方文件,它对我很有用。
如果你想要支持
6379
,您需要设置Allow access only via SSL=No
.我也发现这个官方博客,我认为它对你有用。
宣布发布redis预览版的asp.net会话状态提供程序
我的
web.config
文件。我的测试步骤。
第一步。添加
Session["loginTime"]
在登录方法中。第二步。通过redsmin连接redis缓存https://app.redsmin.com/)
我已经在这个网站注册了验值。
第三步。运行项目。
第四步。检查redsmin中的键和值。