Search code examples
c#asp.netquery-stringquerystringparameter

I have a url in the format www.abc.com/mypage#yourId=ASDF2345. How to read the value of yourid using c#


In my application i have a url in the format

www.abc.com/mypage#yourId=ASDF2345.

How can i read back the value of yourId parameter from the Request object in asp.net , c# ?

If it would have been

www.abc.com/mypage?yourId=ASDF2345,

then i would have got this from the QueryString collection in the Request object. But there is a # before the yourId parameter and its not being provided by the QueryString collection.


Solution

  • The hash you are referring to does not actually get sent to the server by the browser. It's client-side only, C# can't "see" it.

    If you must have that value, you can get it with the document.location.hash property in Javascript and send it back to the server via AJAX.

    This is made easier by jQuery BBQ or jQuery Address, which detect changes in the hash location, and can trigger events.