Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get # value from query string?

Tags:

c#

.net

asp.net

Please help me to get query string value from the URL.

http://test.com/test.aspx#id=test

I tried to access with

Request.QueryString["id"]

Its getting null value.Please suggest how to access id from the url.

Thanks

like image 859
PrateekSaluja Avatar asked Jan 06 '12 12:01

PrateekSaluja


People also ask

Will there be a Season 7 of how do you get away?

If you're wondering whether this twisty series is renewed for Season 7, sadly, the answer is no. ABC decided Season 6 would be the final season of the show, which means the Season 6 finale was the series finale, and we won't be getting another year of Annalise Keating (Viola Davis).

Where can I watch how do you get away season 8?

Right now you can watch How to Get Away with Murder on Netflix. You are able to stream How to Get Away with Murder by renting or purchasing on Amazon Instant Video, iTunes, Google Play, and Vudu.


2 Answers

A query string starts with a question mark ? not a hash #.

Try:

http://test.com/test.aspx?id=test 

Using a hash, you're asking to jump to a named anchor within the document, not providing a query string

like image 28
Grhm Avatar answered Oct 23 '22 06:10

Grhm


I agree with everyone that the # should be a ?, but just FYI:

Note it isn't actually possible get the anchor off the URL, for example:

http://test.com/test.aspx#id=test

The problem is that # specified an anchor in the page, so the browser sees:

http://test.com/test.aspx

And then looks in the page for

<a id="test">Your anchor</a>

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.

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.

More info here c# get complete URL with "#"

like image 110
Ian G Avatar answered Oct 23 '22 07:10

Ian G