Get full query string in C# ASP.NET Get full query string in C# ASP.NET asp.net asp.net

Get full query string in C# ASP.NET


Try Request.Url.Query if you want the raw querystring as a string.


This should work fine for you.

Write this code in the Page_Load event of the page.

string ID = Request.QueryString["id"].ToString();Response.Redirect("http://www.example.com/rendernews.php?id=" + ID);


Request.QueryString returns you a collection of Key/Value pairs representing the Query String. Not a String. Don't think that would cause a Object Reference error though. The reason your getting that is because as Mauro pointed out in the comments. It's QueryString and not Querystring.

Try:

Request.QueryString.ToString();

or

<%                                     string URL = Request.Url.AbsoluteUri     System.Net.WebClient wc = new System.Net.WebClient();    string data = wc.DownloadString(URL);    Response.Output.Write(data);%>

Same as your code but Request.Url.AbsoluteUri will return the full path, including the query string.