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
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IIS redirect 1 77
Creating a route in asp.net webforms 2 32
Client Validating 2 date fields, required & comparison 1 42
Finding the IIS version 5 21
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

791 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