I want to get the complete URL in HttpRequestProcessor pipeline. When I hit https://www.abc.com/#section-1, currently args.RequestUrl is not returning the section path. How to get complete URL with section after #.

  • See this - sitecore.stackexchange.com/questions/2440/… Try this - HttpContext.Current.Request.Url Commented Mar 14, 2023 at 11:44
  • no this is not working . its giving url before #. Commented Mar 14, 2023 at 11:55
  • Why do you want to process the anchor link (#section-1) on the server side? Kindly update your question with more information. Commented Mar 14, 2023 at 13:06

2 Answers 2


It's not possible to retrieve the #anchor from the server side in ASP.NET because the browser won't send these anchor fragments to the server. 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("#");//or use window.location.hash
if(strippedUrl.Length > 1)
    anchorvalue = strippedUrl[1];

Anchor tags (ex: #my-anchor) aren't considered part of a URL and are not sent to servers. You can read more here: https://stackoverflow.com/questions/3067491/is-the-anchor-part-of-a-url-being-sent-to-a-web-server

For example, see this page: https://www.w3.org/TR/html401/struct/links.html

Click around on the table contents links. Notice that additional requests are not made to the server. They are meant to be used as `"jump links".

If you want to expose the anchor to the server, consider serializing it as a query string: ?my-anchor=anchor-name. From there it's business as usual on the server side: args.RequestUrl.PathAndQuery.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.