WebRequest.Create, GET and encoding

  • Thread starter Thread starter diffident
  • Start date Start date
D

diffident

Guest
I am creating a web request with GET method and passing few parameters as query string variables. My requirement is to be able to encode certain characters like :, @, etc. but for some reason WebRequest.Create(url) is not encoding by default. Is it supposed to encode them automatically or do I need to encode programmatically?

string url = http://abcxyz.com?p1=xyz&p2=2&email=none@mail.com&pschedule="date": 3,"equipment": 3,"admin": false,"user": false,"admin": false,&Action=add
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);




So, in the above URL, email parameter's value should be encoded, specifically the "@" character, and "schedule" parameter's value should be encoded specifically ":" and ","

I thought when I created WebRequest.Create() and passed the above URL as the parameter to create method, it would automatically encode these characters. Isn't that the case?

What is the correct way to do it?

Thanks.

Continue reading...
 
Back
Top