Hack Forums
[.NET] The request was aborted: The connection was closed unexpectedly. HTTPWEBREQUEST - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] The request was aborted: The connection was closed unexpectedly. HTTPWEBREQUEST (/showthread.php?tid=3350930)



The request was aborted: The connection was closed unexpectedly. HTTPWEBREQUEST - Justiceā„¢ - Mar 24, 2013

I get this error when I try to send POST Data and log my self in a website. Any ideas?

The request was aborted: The connection was closed unexpectedly.

This is my code

Code
Imports System.Net
Imports System.Text
Imports System.IO

Public Class Form1

    Dim logincookie As CookieContainer

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

  Dim postData As String = "username=" & Username.Text & "&password=" & Password.Text & "&LoginBTN="
  Dim tempCookies As New CookieContainer
  Dim encoding As New UTF8Encoding
  Dim byteData As Byte() = encoding.GetBytes(postData)

  Dim postReq As HttpWebRequest = DirectCast(WebRequest.Create("http://respawn.ca/login.php"), HttpWebRequest)
  postReq.Method = "POST"
  postReq.KeepAlive = True
  postReq.CookieContainer = tempCookies
  postReq.ContentType = "application/x-www-form-urlencoded"
  postReq.Referer = "http://respawn.ca/login.php"
  postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
  postReq.ContentLength = byteData.Length

  Dim postreqstream As Stream = postReq.GetRequestStream()
  postreqstream.Write(byteData, 0, byteData.Length)
  postreqstream.Close()
  Dim postresponse As HttpWebResponse

  postresponse = DirectCast(postReq.GetResponse(), HttpWebResponse)
  tempCookies.Add(postresponse.Cookies)
  logincookie = tempCookies
  Dim postreqreader As New StreamReader(postresponse.GetResponseStream())

  Dim thepage As String = postreqreader.ReadToEnd

  RichTextBox1.Text = thepage

    End Sub

End Class

As you can see from the code, I'm trying to make myself a portable version of Respawn Stresser for myself. I'm quite new to httpwebrequest, so any help is appreciated.

EDIT: Just realized that I sounded like I didn't know what the error meant. I am wondering how I can fix that.

I think the http headers may be wrong, but I am not sure.


* - Helius - Mar 25, 2013

use your favorite browser to login and use fiddler to check the headers ...