How to add query string to httpwebrequest
I want to add some querystrings to httpwebrequest, however I cannot f开发者_如何学Goind any property? I remembered there is a QueryString dictionary which I can use before.
The best way to add a query string is as follows:
var targetUri = new Uri("http://www.example.org?queryString=a&b=c");
var webRequest = (HttpWebRequest)WebRequest.Create(targetUri);
var webRequestResponse = webRequest.GetResponse();
Remember: If you're using user input to construct the Uri, ensure that you validate it, escape it and don't trust it.
精彩评论