Retrieving anchor link in URL for ASP.NET

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.

You can use some JavaScript code in the body onLoad event to check for an anchor and send it back to the server using Ajax.

var anchorValue;
var url = document.location;
var strippedUrl = url.toString().split("#");
if(strippedUrl.Length > 1)
    anchorvalue = strippedUrl[1];

Ref: Retrieving the anchor value from a URL

Leave a Comment