0

I have an asp.net application, that onclick takes the user to a different part of the page. The onclick causes a postback, and when the page loads, the part of the page that I want to go to is set to display none

So, what I need to do is detect the presence of #apply in the URL.

This is proving more difficult than I would expect.

I have tried:

string path = HttpContext.Current.Request.RawUrl;
string path = HttpContext.Current.Request.Url.Fragment;

and every other option I could find, including the answer from Get part of a URL after domain using Regex, which I thought would work, although I used URL not uri.

Is it possible to do this?

Community
  • 1
  • 1
Alex
  • 3,730
  • 9
  • 43
  • 94

2 Answers2

1

No. The hash URL fragment is not send to the server, so you can't access it. That part is just for client side purposes, so you only have access to it there.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
1

The #apply is used on the client only, so you can't access it server-side.

If you are using WebForms, this might help:

Page.MaintainScrollPositionOnPostback="true"

https://msdn.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback(v=vs.110).aspx

Dave S
  • 1,403
  • 1
  • 15
  • 23