I have run into a trivial(?) problem when trying to get the whole URL of a c# page.
The url contains the "#"-link ref char. And i would like that to when I grab the URL
Eg. http://localhost/site/page.aspx?var=1&var=2#link
I have tried Request.URL, Request.Querystring etc, it only returns up to the "#"-char.
Is there any way to grab even the last part?
Thanks in advance
That is not possible using server code only. The part after the # is not sent in the request at all, it never leaves the browser.
If you want the part after the # you have to copy it using Javascript before the request is sent to the server, and put the value in the querystring.
Your problem is that # specified an anchor in the page, so the browser sees:
And then looks in the page for
As this is client side you need to escape the # from the URL - you can't get it on the server because the browser's already stripped it off.
Are you sure that the stuff after the # isn't sent to the server. I'm pretty sure i made a test with an ajax-app some years ago where the url could be copied and sent to people without javascript by only modifiying the stuff after the # in the url when browsing around with javascript enabled.
That was in PHP and the browser was probably IE6.