Escape & in App.config

泄露秘密 提交于 2019-12-18 12:45:34

问题


I have the following piece of config in my App.config file:

<add key="ConnectionString" 
     value="INITIAL CATALOG=myDatabase;DATA SOURCE=myServer;User ID=myUser;Password=!&myPass99;"/>

The above connection string is rejected by Visual Studio intellisense. It says entity myPass99 not defined. The problem is caused by the & in the password.

How do I escape it?


回答1:


Escape the ampersand by using &amp; in place of the &

As an FYI, see here for further characters: What characters do I need to escape in XML documents?



来源:https://stackoverflow.com/questions/10883745/escape-in-app-config

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!