asp.net-mvc - 在门户上设置 Windows Azure Redis 连接字符串

标签 asp.net-mvc azure redis stackexchange.redis

在我维护了 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>

但是好像没捡到。你能告诉我为什么吗?

enter image description here

最佳答案

这是诀窍。干杯 :)

#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/

相关文章:

javascript - 绑定(bind)下拉(选择)列表的初始/默认值

java - 如何下载azure函数应用程序的代码

azure - Xamarin.iOS 无法在 iOS 13.1.2 中向 Azure 通知中心注册

azure - 是否可以查询 Azure SearchServiceClient 以获取文档属性列表

node.js - 我如何订阅所有可用的 channel ?

transactions - 如果 Redis 在事务中间触发快照怎么办?

asp.net-mvc - asp.net mvc 路由与 IIS7 中的物理路径冲突

c# - 在单元测试中设置 HttpContext.Current.Application 键

jquery - 在 MVC 布局中折叠边栏

redis - 在 Redis 中列出所有事件/订阅的 channel