开发者

How to add query string to httpwebrequest

开发者 https://www.devze.com 2023-02-11 15:53 出处:网络
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

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消