1

I have created a web service method in Asp.Net and getting a response in XML. In the response there are too many special characters.

How to deal with these special character, because I am getting errors like this:

"Specified value has Invalid CRLF characters" 

Which method do I use? Is HttpUtility good for this one?

If yes, is there a sample?

My code: I am using Regex.Replace but getting an error:

 string link = "http://xxx.xx.x"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(link); request.Connection = Regex.Replace(newstr.m12345(str, name, pwd, id), "[^\"a-zA-Z0-9_?<>+=./: -]", ""); string connection = request.Connection; return connection; 
1
  • @JohnStephen Thnx man, I saw that link, about CData, but not clearly perfect!!can you show me by example? Commented Aug 1, 2014 at 6:05

1 Answer 1

1

Ok, I got the answer, with the help of using XDocument.

string link = "http://xxx.xx.x"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(link); XDocument doc = XDocument.Parse(newstr.m12345(str, name, pwd, id)); string connection = Convert.ToString(doc); return connection; 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.