简体   繁体   中英

How do I do a postback to a CGI service

You're looking for the WebClient class.

For example: ( 2 nd EDIT : With GZIP; this code is tested and actually works)

string response;
using (var client = new WebClient()) {
    byte[] bytes = client.DownloadData(url);
    using(var reader = new StreamReader(new GZipStream(new MemoryStream(bytes), CompressionMode.Decompress)))
        response = reader.ReadToEnd();
}

However, if the URL returns raw XML, you can also load the XML directly from the URL, like this:

var doc = XDocument.Load(url);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM