0
public static string MakePOSTWebREquest(string url, string contentType, string postData)
{
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
        if (!String.IsNullOrEmpty(contentType))
        {
            req.ContentType = contentType;
        }
        else
        {
            req.ContentType = "application/x-www-form-urlencoded";
        }
        req.Method = "POST";

        byte[] pbytes = Encoding.UTF8.GetBytes("list=");
        byte[] arr = Encoding.UTF8.GetBytes(postData);
        req.ContentType = "application/x-www-form-urlencoded";
        req.ContentLength = arr.Length + pbytes.Length;
        Stream stream = req.GetRequestStream(); //error stream does not allows seek operation
        stream.Write(pbytes, 0, pbytes.Length);
        stream.Write(arr, 0, arr.Length);
        stream.Close();

        HttpWebResponse webResp = (HttpWebResponse)req.GetResponse();

        //Now, we read the response (the string), and output it.
        Stream respStream = webResp.GetResponseStream();
        GZipStream zStream = new GZipStream(respStream, CompressionMode.Decompress);
        StreamReader reader = new StreamReader(zStream);
        string respData = reader.ReadToEnd();

        return respData;
}

I am getting an exception that says

This stream does not supports seek operation.

What are the possible solutions? This code runs for some time and after some time it gives a error message of The operation has timed out.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Prashant Kumar
  • 239
  • 1
  • 6
  • 15

0 Answers0