QueryString 中带有空格的 GET 请求会导致代码崩溃

发布于 2024-10-08 03:11:17 字数 173 浏览 0 评论 0原文

简而言之,我的代码工作正常并从 GET 请求返回 JSON,但是当 QueryString 的值对之一中有空格时,服务将关闭。即使在 IDE 中调试时也不会引发异常,但使用 Fiddler 执行 GET 请求时我会收到“HTTP 错误 400 - 错误请求” - 可能是因为服务器刚刚关闭(Visual Studio 开发服务器)。

Simply put my code is working fine and returning JSON from GET requests, but when there is a space in one of the value pairs of the QueryString the Service shuts down. Even when debugging in the IDE no exception is thrown, although, using Fiddler to perform the GET request I get back a "HTTP Error 400 - Bad Request" - probably because the server's just shut down (the Visual Studio development Server).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

南…巷孤猫 2024-10-15 03:11:17

空格不是查询字符串的合法部分,应替换为 +(加号)

Spaces aren't a legal part of the querystring, and should be replaced with a + (plus sign)

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