I have a string that stores a URL that contains %26 for & at one point in the URL, because that is required for the URL that I am trying to call.
I print the URL string to the console before making the
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myURL);
and if I copy and paste the URL that is printed, then I am able to get to the desired target.
However, when I connect and ge开发者_开发知识库t the response with
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
it fails (the URL makes an update to another page, and the update is made when I copy and paste the URL that is printed, but not when I run the HttpWebResponse...).
Does this have something to do with the encoding/decoding of the URL string when the WebRequest is created?
Any help would be appreciated, thanks.
Try encoding your url. Try this link URL Encode
精彩评论