Solved

How to enter a string that contains a double quote in web.config

Posted on 2009-05-10
3
741 Views
Last Modified: 2012-05-06
Hi

I need to pass a string of characters to my application from web.config, the problem being that the string contains a double quote and the <> characters which in ASP.NET is fine because I can add an escape character in front of it but in the web.config this gives me an error because
the application thinks my string ends with the double quote regardeless of the escape character and the <> chars confuse it as it thinks they are part of the tag.

So how do I define a string such as

"¬()*^%$£\"!?\<\>,:;@~#{}[]+=|_`+\\'"

in web.config.

Thanks
Sam
0
Comment
Question by:Samm1502
3 Comments
 
LVL 4

Expert Comment

by:cauos
ID: 24348236
0
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 500 total points
ID: 24352375
hi Samm1502,
There are 2 common approaches that using to resolve these escape characters issue.
First, you can use HTML mapping for these special characters.
eg:
< can be represented as <
> can be represented as >
You can refer this chart for further details:
http://www.trans4mind.com/personal_development/HTMLGuide/specialCharacters.htm

But, most of the people can't adapt to these alternative conversion due to its complexity and redundant tasks for entry purpose. Thus, second option is using CDATA[] to escape all the text that allowed in xml format. This setting is more easy to apply compare option 1.
You can check more details for CDATA[] block as mentioned:
http://www.w3schools.com/XML/xml_cdata.asp

However, you need to create the own XML wrapper classes(check http://devpinoy.org/blogs/jakelite/archive/2009/03/22/how-to-add-cdata-or-text-in-a-configurationelement.aspx) in order to use CDATA block inside config. file as asked.

Please check this similar question that asked:
http://stackoverflow.com/questions/422230/how-can-i-include-a-cdata-section-in-a-configurationelement


0
 

Author Closing Comment

by:Samm1502
ID: 31579907
I used the HTML encodings and that works perfectly thanks.
Sam
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now