2016-05-17 69 views
0

在Redis辅助方法上,我维护了2个Redis连接字符串。一个用于local,另一个用于Azure redis server。每当我需要发布时,我都有手动改变它。我的应用程序是ASP.net MVC(SPA)应用程序。在门户网站上设置Windows Azure Redis连接字符串

问:那么有什么地方可以在Azure门户上设置发布的Redis connection string或者我在发布时进行发布?

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

+0

您的应用程序的部署方式 - 网络应用,云服务或虚拟机? –

+0

@GauravMantri'Web Apps' – Sampath

+0

您可以查看web.config转换并在web.config.release文件中放入适当的连接字符串。因此,当应用程序以“释放”模式构建时,它会从那里获取正确的连接字符串。 –

回答

0

这里是trick.Cheers :)

#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 
相关问题