0

Possible Duplicate:
How to get Url Hash (#) from server side

I have hash parameters in url

Can any body please help me to how to read Hash parameters value from Url using C#?

www.example.com/default.aspx#!type=1

How to read value of type?

Community
  • 1
  • 1
krishna
  • 845
  • 2
  • 8
  • 5

2 Answers2

11

The hash part is only used and available on the client. You cannot read it from ASP.NET / C#.

Samuel Neff
  • 73,278
  • 17
  • 138
  • 182
-6
  1. Split the URL at the hash (#).
  2. Then split the second element from above at each ampersand (&)
  3. Then split each of those at the equals (=) sign.

You will then have all the parameters and values.


If this was asking about a ASP.net application, you want to use Request.QueryString["type"] to get the value.

zsalzbank
  • 9,685
  • 1
  • 26
  • 39
  • 1
    Values after # aren't passed to the webserver. for http://localhost/default.aspx#test, Request.RawUrl and Request.Url.ToString() return http://localhost/default.aspx. – lukiffer Jan 06 '11 at 02:35
  • the asker wasn't really clear on how they will be using the code. this is how it would be done if the URL was passed to the program, not if it was running on a server somewhere and each request needed to read the parameter – zsalzbank Jan 06 '11 at 02:37
  • type is not a querystring parameter, so you won't be able to access it with *Request.QueryString["type"]* in asp.net – Pauli Østerø Jan 06 '11 at 02:41