how to get the value from address bar entered by client?

asp.net, c#, web-applications

Solution

You have to use Request.QueryString to get value any param passed to the page. The result, stored in a page variable, can be used to retrieve the needed data.

string usr = Request.QueryString["usr"];

Problem

I don't know how to put the title but i will try to explain it the requirement here. Normally user entered an URL in address bar in browser, for example www.example.com, then click a link and redirect to another page www.example.com/test.aspx. Alternatively, user also can just enter/type www.example.com/test.aspx from address bar if they know the full path. So, i required to write a code where user can type an URL in address bar, for example www.example.com/test.aspx?usr="www.test.com". (note: with addition usr="www.test.com") The "usr="www.test.com" after www.example.com/test.aspx? contain a value that stored in database. So, when the user type www.example.com/test.aspx?usr="www.test.com" it will search the database for matching www.test.com and do some process if found. How can i achieve this.

Original source

Related problems