gpt4 book ai didi

c# - 当 # 提供而不是时,如何在 C# 中分离查询字符串?

转载 作者:太空宇宙 更新时间:2023-11-03 22:31:53 25 4
gpt4 key购买 nike

我使用 .NET 4.7、MVC5、C#

我从第 3 方端点收到一个查询字符串,其中包含 # 而不是 ?即:

endpoint#code=123456&parm2=123....

代替:

endpoint?code=123456&parm2=123....

我常用的代码:

string[] codes = Request.Params.GetValues("code")

string code = Request.QueryString["code"];

不会处理这个。一直返回 null。我无法让第 3 方更改此设置,显然它是 oauth2 规范的一部分,称为“哈希片段”。

是否有可能获得完整的返回 url 并通过字符串处理例程提取相关位?

虽然我在调试器中看不到完整的 URL,但如果我让端点完成,我会在浏览器的 URL 框中看到带有 # 的完整查询字符串。希望我能在代码中得到这个来拼接。

想法?

提前致谢。

最佳答案

根据RFC 2396, section 4,片段(# 符号后的所有内容)未发送到服务器:

However, "the URI" that results from such areference includes only the absolute URI after the fragmentidentifier (if any) is removed and after any relative URI is resolvedto its absolute form.

无法在服务器端检索它。

关于c# - 当 # 提供而不是时,如何在 C# 中分离查询字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57160990/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com