web.config 中的特殊字符

发布于 2024-10-09 11:14:44 字数 642 浏览 0 评论 0原文

我在 web.config 文件中为 3.5 Web 应用程序创建了一个自定义配置部分。自定义配置包含下面列出的特殊字符。

  <add Key="2" String="â€"/>
  <add Key="3" String="148"/>
  <add Key="4" String="!X"/>
  <add Key="5" String="¡§"/>
  <add Key="6" String="¡¦"/>
  <add Key="7" String="¡¨"/>
  <add Key="8" String="’" />
  <add Key="9" String="–" />

我目前的 web.config 的 xml 类型定义如下。

<?xml version="1.0"?>

这在一个开发环境中工作正常,但是当我将应用程序迁移到另一个环境时,我在键 2 的字符串上收到 xml 解析错误。当我用标准 alpha 字符替换每个配置条目的所有字符串定义时,应用程序工作正常。有没有办法强制以同样的方式读取 XML?我已经研究了 xml 定义标记的编码属性,只是不确定将其设置为什么。任何指导将不胜感激。提前致谢。

I've create a custom configuration section in my web.config file for my 3.5 web application. The custom configuration contains special characters listed below.

  <add Key="2" String="â€"/>
  <add Key="3" String="148"/>
  <add Key="4" String="!X"/>
  <add Key="5" String="¡§"/>
  <add Key="6" String="¡¦"/>
  <add Key="7" String="¡¨"/>
  <add Key="8" String="’" />
  <add Key="9" String="–" />

I currently have the xml type of the web.config defined as below.

<?xml version="1.0"?>

This works fine in one development environment, but when I migrate the application to another environment I get an xml parsing error on the string for Key 2. When I replace all the string definitions for each config entry with standard alpha chars, the application works fine. Is there a way to enforce the XML to be read the same way? I have looked into the encoding attribute for the xml definition tag, just not positive what to set it to. Any guidance would be well appreciated. Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゞ记忆︶ㄣ 2024-10-16 11:14:44

我建议将编码设置为“utf-8”。确保该文件实际上也保存为 utf-8。

I recommend setting the encoding to "utf-8". Make sure the file is also actually saved as utf-8.

遮了一弯 2024-10-16 11:14:44

您是否手动将这些内容输入到 web.config 文件中?不能对字符串值进行 HTML 编码吗?

Are you typing these into your web.config file manually? Can't you just HTML-encode your string values?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文