Reputation: 311
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;
Upvotes: 1
Views: 1294
Reputation: 311
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;
Upvotes: 1