WebRequest 正在解码?

发布于 2024-10-14 15:24:14 字数 506 浏览 6 评论 0原文

我有一个存储 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

他夏了夏天 2024-10-21 15:24:14

尝试对您的网址进行编码。尝试此链接URL 编码

Try encoding your url. Try this link URL Encode

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文