http calls with a parameter value that contains &

S

SM

Hi,
I have an issue with passing parameter values to an http call.Please find
the code segment below



string sUrl = "http://mywebw.uweb.uif.com/Request_Handler/RequestHandler?";
sUrl = sUrl + "okaction=get_distribution_list&er_title=" + "yters&RM orang
Committee.ikin" + "&cn=" + "(e-mail address removed)";



httpReq = (HttpWebRequest)WebRequest.Create(sUrl);
//httpReq.Timeout = 10000;
//WebRequest wr = WebRequest.Create(sUrl1);
httpReq.Credentials = CredentialCache.DefaultCredentials;
httpRes = (HttpWebResponse)httpReq.GetResponse();


Stream st = httpRes.GetResponseStream();
sr = new StreamReader(st , Encoding.UTF8);


this http call should read the url with the given parameters and return a
control number, however , it doesn't
return the control number because parameter er_title has "&" in the value
"yters&RM orang Committee.ikin"
and pass just "yters" to the destination web site.
Let me know if anybody faced this issue before and knows how to resolve.
 
J

Josh Twist

You need to Url encode the values.

This can be done programmatically using the
HttpUtility.UrlEncode("stringstringthatmightcontainweirdcharacters")
function.

For your information, an ampersand (&) becomes %26

Josh
http://www.thejoyofcode.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top