Solved

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

Posted on 2009-05-10
3
751 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

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 …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 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