WebRequest 正在解码?
我有一个存储 URL 的字符串,其中包含 %26 for & URL 中的某一点,因为这是我尝试调用的 URL 所必需的。
我在制作之前将 URL 字符串打印到控制台
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(myURL);
,如果我复制并粘贴打印的 URL,那么我就能够到达所需的目标。
但是,当我连接并获取响应时,
HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();
它会失败(URL 对另一个页面进行更新,并且在我复制并粘贴打印的 URL 时进行更新,但在运行 HttpWebResponse 时则不会进行更新...)。
这与创建WebRequest时URL字符串的编码/解码有关系吗?
任何帮助将不胜感激,谢谢。
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 get 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试对您的网址进行编码。尝试此链接URL 编码
Try encoding your url. Try this link URL Encode