Special Characters in web.config File

It seems like I tried several variations, but I couldn’t get it to work. I want to add this line to my app settings -

   value="Steve <steve@mindscapecreative.com>" />

value=“Steve <steve@mindscapecreative.com>” />[/left]


Why would you need speical characters in the web.config? Which is xml.

You answered your own question. Angle brackets as vakues must be escaped in an XML document. For example:

	<foo bar="<" />

The above is not valid XML.

	<foo bar="\<" />

The above is the correct representation.

Thats not my point.

Why use angle brackets at all? Can’t this be programically added later?

Why add formating/misc. markup in the XML (or any datasource). The whole point of data storage is to allow for it to be manipulated at a later time. Adding mark-up limits this ability. Unless you create methods to remove the added markup. In that case it would just be easier to omit them.

The email address shown in the example isn’t markup. It’s so that when a user gets the email it’s displayed as the person’s name instead of just an email address in their client. He’s probably not going to do anything with that piece of data other than retrieve it and spit it back out unchanged.

Sorry - let me clarify.

I have script that sends email. That variable is the from address. In formating an email address, if you put brackets in the address the recepient only sees the name, not the email. This ‘Steve Olson’ looks a lot cleaner than ‘steve@someaddress.com’ in the header of Outlook or whatever email program you are using.

If I simply escape the HTML, then the code is passed and not the brackets.

Better sample of what I want to change -

Dim sTo as String = txtName.Text & " <" & txtEmail.Text & ">"
[b]Dim sFrom as String = "Steve Olson <steve@someaddress.com>"[/b]

Isn’t there a ‘![CDATA[…]]’ or something?

So, is the config file a differently formatted XML?

Why not just store the addressing in two values, fromName and fromEMail, then compile it in code.

<add key=“fromName” value=“My Name” />
<add key=“fromEMail” value=“me@example.com” />

This allows you to also use the name and address seperately. For example, in the email body or onscreen display.

BTW… CDATA usage is only valid when used thusly…

<element attr=“value” … >

…raw as-is text…

] ]>