【问题标题】:How to get # part of the Url from HttpContext.Current.Request [duplicate]如何从 HttpContext.Current.Request 中获取 URL 的 # 部分 [重复]
【发布时间】:2017-12-04 20:23:27
【问题描述】:

我正在尝试在当前应用程序中使用 HttpContext.Current.Request 读取 Url 的 # 部分。例如,我正在阅读一个网址https://www.example.com/page1/page2#divId

HttpContext.Current.Request.Url.RawUrl 返回“https://www.example.com/page1/page2”并排除其中的“#divId”部分。我没有在 Request 对象中找到它。

需要快速帮助。

谢谢 钱达纳

【问题讨论】:

  • 那部分是否发送到服务器?检查网络浏览器中的网络调试工具,看看它是否包含在请求中。
  • URL 片段不发送到服务器。

标签: c# .net httpcontext


【解决方案1】:

#之后的url部分称为fragment,不会发送到服务器。它仅供客户端使用。

也检查一下:Is the URL fragment identifier sent to the server?

【讨论】:

    【解决方案2】:

    可能是 Uri.Fragment 属性对你有帮助。

    https://msdn.microsoft.com/en-us/library/system.uri.fragment.aspx

    【讨论】:

      猜你喜欢
      • 2012-08-28
      • 1970-01-01
      • 2021-07-18
      • 2015-12-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多