1

I need to be able to get at the full URL of the page The page url is like this

http://localhost:12365/Dashboard.aspx#access_token=adfgafdg73e9c4ggg186fbfcf05e775a6f2gggd8&expires_in=3600&token_type=Bearer&state=zxv

In this URL, after # how to get the access_token value?

Mahendra
  • 317
  • 2
  • 4
  • 16

1 Answers1

8

You cannot. Anything in the fragment (the portion from the # onwards) is not sent to the server. Only the client can look at that, which you can do in javascript via window.location.hash.

One useful trick that some sites use, is to use the fragment to prevent user data appearing in http request logs; the page might be /foo/bar#something, which loads /foo/bar, then client-side javascript looks at the fragment and does an ajax POST to get data to load the content. This works because most http logs record the GET uri but not POST form bodies, so the #something isn't captured in the logs.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900