在服务器端使用url hash获取当前页面的完整URL

时间:2014-01-03 10:04:31

标签: c# asp.net url

我无法获得我正在处理的页面的完整网址。这是我想要获取的网址http://localhost:54570/Shipment/ShipmentDetails.aspx?HawbBLNo=NEC00000004#BFT此代码的结果仅为http://local/Shipment/ShipmentDetails.aspx?HawbBLNo=NEC00000004

protected void btnSave_Click(object sender, EventArgs e)
{
    url = HttpContext.Current.Request.Url.AbsoluteUri;
    UpdateDetails();
    Response.Redirect(url);
}

2 个答案:

答案 0 :(得分:8)

无法在服务器端获取哈希内容,因为哈希永远不会发布到服务器

针对某些技巧How to get Url Hash (#) from server side

查看此问题

答案 1 :(得分:3)

  

无法从ASP.NET

中的服务器端检索#anchor      

这是一个客户端标志,用于告诉浏览器移动到页面中的特定位置。

请看一下同样的讨论

Retrieving Anchor Link In URL for ASP.Net

Get full URL with hash to use as ReturnUrl