Get full query string in C# ASP.NET

后端 未结 6 1530
死守一世寂寞
死守一世寂寞 2020-12-29 19:30

As a PHP programmer I\'m used to using $_GET to retrieve the HTTP query string... and if I need the whole string, theres loads of ways to do it.

In ASP however, I c

6条回答
  •  感情败类
    2020-12-29 20:01

    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.

提交回复
热议问题