The underlying connection was closed: The connection was closed unexpectedly

2

I'm designing in WebForm, and I'm passing an array to a method that will make a post for a specific URL. However, after I run the project and send the array to the method, it breaks with the error reported in the title.

   private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {
        HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://MINHAURL.COM/QUE-RECEBE-O-POST/");
        request.Method = "POST";
        request.Accept = "application/json";
        request.UserAgent = "curl/7.37.0";
        request.ContentType = "application/x-www-form-urlencoded";
        request.KeepAlive = false;

        using (var streamWriter = new StreamWriter(request.GetRequestStream()))
        {
            string data = "browser=Win7x64-C1|Chrome32|1024x768&url=https://MINHAURL.COM/QUE-RECEBE-O-POST/";

            streamWriter.Write(data);
        }

        WebResponse response = request.GetResponse();

    }

    private void button1_Click(object sender, EventArgs e)
    {
         var user = new Usuarios();
        var lista = new string[]
        {
            user.name,
            user.dt_nascimento,
            user.cidade
        };

        webBrowser1_DocumentCompleted(lista, null);
    }
    
asked by anonymous 14.10.2015 / 03:59

0 answers