Getting the full url of the current page with url

2019-04-24 11:29发布

问题:

I cant get the full url of the page that I am working on. This is the url that I want to get http://localhost:54570/Shipment/ShipmentDetails.aspx?HawbBLNo=NEC00000004#BFTThe result is only http://local/Shipment/ShipmentDetails.aspx?HawbBLNo=NEC00000004 on this code

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

回答1:

there is no way to get hash content on server side because hash are never posted to the server

see this question for some tricks How to get Url Hash (#) from server side



回答2:

It's not possible to retrieve the #anchor from the server side in ASP.NET

This is a client-side flag to tell the browser to move to a specific place within the page.

Please take a look at this same discussion

Retrieving Anchor Link In URL for ASP.Net

and

Get full URL with hash to use as ReturnUrl



标签: c# asp.net url