?
Solved

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

Posted on 2009-05-10
3
Medium Priority
?
779 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

765 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