【问题标题】:Web.config: Escape quotes for password in provider connection string inside the connection string doesn't workWeb.config:连接字符串内的提供程序连接字符串中密码的转义引号不起作用
【发布时间】:2023-03-20 08:47:01
【问题描述】:

我有以下连接字符串

    <add name="EntitiesContainer"         
    connectionString="metadata=...;provider=System.Data.SqlClient;
    provider connection string=&quot;Data Source=server;Initial Catalog=dbXYZ;User 
    ID=userxyz;Password=<password>;MultipleActiveResultSets=True&quot;"         
    providerName="System.Data.EntityClient"/>

我的问题是,我不能在提供程序连接字符串密码中使用引号。 我尝试根据有关堆栈溢出和 Mladen Prajdić 博客的几篇帖子来转义密码:https://weblogs.sqlteam.com/mladenp/2008/10/21/different-ways-how-to-escape-an-xml-string-in-c/

我尝试使用“与 &quote、System.Security.SecurityElement.Escape、XMLWriter、System.Security.SecurityElement.Escape 和 System.Web.HttpUtility.HtmlEncode() 来转义类似 'hello"World' 的密码.

我想问题在于,我在连接字符串中有一个封装的字符串(提供者连接字符串)。

有什么想法吗?

非常感谢!

【问题讨论】:

  • 使用&amp;amp;quot;?

标签: c# asp.net-mvc connection-string


【解决方案1】:

如果您想知道值将如何在 web.config 中编码:

  • 转到管理工具 => IIS 管理器

  • 使用或不使用 web.config 打开站点和任何 Web 应用程序文件夹(将被创建)

  • 从右侧转到功能视图:打开应用程序设置或连接字符串 查看和添加或修改相关值并保存。

  • 通过文件资源管理器打开 web.config 并查看保存的值。

【讨论】:

  • 非常感谢!这是一个很好的建议!不幸的是,即使我通过 IIS 在提供程序连接字符串(子字符串)中写入密码,它也不起作用。
  • 有什么问题?
猜你喜欢
  • 1970-01-01
  • 2012-06-18
  • 1970-01-01
  • 1970-01-01
  • 2010-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-10-18
相关资源
最近更新 更多