1

I'm trying to read the # part of an Url using HttpContext.Current.Request in my current application. For example, I've reading a Url https://www.example.com/page1/page2#divId.

The HttpContext.Current.Request.Url.RawUrl returns "https://www.example.com/page1/page2" and excluds "#divId" part of it. I didn't find it in the Request object.

A quick help is required.

Thanks Chandana

Chandana
  • 145
  • 1
  • 11
  • Is that part even sent to the server? Check the network debugging tools in your web browser and see if it's even included in the request. – David Jun 30 '17 at 19:47
  • 2
    URL fragments are not sent to the server. –  Jun 30 '17 at 19:47

2 Answers2

3

The part of the url after the # is called fragment and is not sent to the server. It's intended to be used client side only.

Check this too: Is the URL fragment identifier sent to the server?

jspurim
  • 925
  • 8
  • 25
1

May be Uri.Fragment Property is help for you.

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

Andrey Ravkov
  • 1,268
  • 12
  • 21