在我维护了 2 个 Redis 连接字符串的 redis 辅助方法上。一个用于 local
,另一个用于 Azure redis 服务器
。每次我需要发布,我必须手动更改它。我的应用程序是 ASP.net MVC (SPA) 应用程序。
问:那么有什么地方可以在 Azure 门户上或我进行发布时设置发布的 Redis 连接字符串
吗?
public class RedisConnectorHelper
{
private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("localhost,ConnectTimeout=10000"));//local host
//private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
// new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("Myredis.redis.cache.windows.net:6380,password=mypassword,ssl=True,abortConnect=False"));//production
}
更新:
我已经在 web.config.release
文件中设置了它,如下所示。
<connectionStrings>
<add name="Abp.Redis.Cache" connectionString="Myredis.redis.cache.windows.net:6380,password=mypassword=,ssl=True,abortConnect=False" />
</connectionStrings>
但是好像没捡到。你能告诉我为什么吗?
最佳答案
这是诀窍。干杯 :)
#if DEBUG
private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("localhost,ConnectTimeout=10000"));//local host
#else
private static readonly Lazy<ConnectionMultiplexer> LazyConnection =
new Lazy<ConnectionMultiplexer>(() => ConnectionMultiplexer.Connect("Myredis.redis.cache.windows.net:6380,password=mypassword,ssl=True,abortConnect=False"));//production
#endif
关于asp.net-mvc - 在门户上设置 Windows Azure Redis 连接字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37275265/