Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store string with html content in appsettings

Tags:

c#

I've written some email code and I'm required to send all emails with a signature.

I was asked to store the signature in the appsettings of the web.config file.

I'm not sure if this is the correct place. Can someone advise me otherwise? As far as I know there is only going to be one email signature in there.

I tried:

<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>

I'm unsure however how to escape for the link. I had a look at some suggestions and tried:

<a href=""http://www.thebiscuitfactory.com"">The Biscuit Factory</a>

and I tried:

<a href=\"http://www.thebiscuitfactory.com\">The Biscuit Factory</a>

but couldn't get it to work.

Can anyone tell me how to escape this and also if there is somewhere else this would be better stored?

like image 526
user2005657 Avatar asked May 08 '13 22:05

user2005657


1 Answers

Did you already try changing < and > into &lt; and &gt; ?

< and > are not allowed inside an xml (appsettings) attribute.

Also for the " you can try using &quot;

So in the end you have this:

<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>
like image 105
nl-x Avatar answered Sep 20 '22 11:09

nl-x