Solved

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

Posted on 2009-05-10
3
763 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

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