如何在appsettings中存储带有html内容的字符串

use*_*657 5 c#

我写了一些电子邮件代码,我需要发送所有带签名的电子邮件.

我被要求将签名存储在web.config文件的appsettings中.

我不确定这是不是正确的地方.有人可以告诉我吗?据我所知,那里只会有一个电子邮件签名.

我试过了:

<appSettings>
<add key="CompanyEmailSignature" value="The Biscuit Factory\n\r
        Somewhere in the Bahamas\n\r
        <a href="http://www.thebiscuitfactory.com">The Biscuit Factory</a>\n\r
        Our mission is to make tasty biscuits" />

    </appSettings>
Run Code Online (Sandbox Code Playgroud)

但我不确定如何逃避链接.我看了一些建议并尝试过:

<a href=""http://www.thebiscuitfactory.com"">The Biscuit Factory</a>
Run Code Online (Sandbox Code Playgroud)

我试过了:

<a href=\"http://www.thebiscuitfactory.com\">The Biscuit Factory</a>
Run Code Online (Sandbox Code Playgroud)

但无法让它发挥作用.

任何人都可以告诉我如何逃避这一点,如果有其他地方,这将更好地存储?

nl-*_*l-x 11

你已经尝试改变<>&lt;&gt;

<并且>不允许在xml(appsettings)属性中.

"可以尝试使用&quot;

所以最后你有这个:

<appSettings>
<add key="CompanyEmailSignature" value="
    The Biscuit Factory\n\r
    Somewhere in the Bahamas\n\r
    &lt;a href=&quot;http://www.thebiscuitfactory.com&quot;&gt;The Biscuit Factory&lt;/a&gt;\n\r
    Our mission is to make tasty biscuits
" />
</appSettings>
Run Code Online (Sandbox Code Playgroud)

  • @jclozano不,这不是必要的. (4认同)