相关疑难解决方法(0)

检索并使用Windows Azure的连接字符串?

我在Azure管理门户配置 - >连接字符串(链接资源)中配置了连接字符串:

在此输入图像描述

这些连接字符串对什么有用?

我试着删除conn.来自web.config文件的字符串,所以应该从这里读取,但事实并非如此.

还有其他方法吗?

基本上我希望这些连接字符串覆盖web.config中的连接字符串以在生产环境中使用.

我在方法中添加了以下内容Application_Start:

var sb = new StringBuilder();
var appConfig = ConfigurationManager.OpenMachineConfiguration();  
foreach (ConnectionStringSettings conStr in appConfig.ConnectionStrings.ConnectionStrings)
  sb.AppendFormat("Name: {0}, ConnectionString: {1}\n", conStr.Name, conStr.ConnectionString);
throw new Exception(sb.ToString());
Run Code Online (Sandbox Code Playgroud)

这是结果:

名称:LocalSqlServer,ConnectionString:data source =.\ SQLEXPRESS; Integrated Security = SSPI; AttachDBFilename = | DataDirectory | aspnetdb.mdf; User Instance = true

我也尝试了以上,ConfigurationManager.ConnectionStrings服务器(Azure)连接字符串不存在.

c# connection-string web-config azure

9
推荐指数
1
解决办法
7667
查看次数

标签 统计

azure ×1

c# ×1

connection-string ×1

web-config ×1