This operation cannot be performed after the request has been submitted

BuckleyInDaHouse

New member
Joined
Nov 27, 2007
Messages
2
Programming Experience
Beginner
VB.NET:
System.InvalidOperationException was unhandled
  Message="This operation cannot be performed after the request has been submitted."
  Source="System"
  StackTrace:
       at System.Net.HttpWebRequest.set_Proxy(IWebProxy value)
       at Proxy_Checker.Module1.CheckProxies(ArrayList TheProxyArray, String threadid) in C:\Documents and Settings\HP_Owner\My Documents\Visual Studio 2005\Projects\Proxy Checker\Proxy Checker\Module1.vb:line 79
       at Proxy_Checker.Module1.Main() in C:\Documents and Settings\HP_Owner\My Documents\Visual Studio 2005\Projects\Proxy Checker\Proxy Checker\Module1.vb:line 43

Thats the error code I got.

How do I fix this problem? This is the only piece of code that is causing problems, the rest of the code is fine trust me.

VB.NET:
Public Sub CheckProxies(ByVal TheProxyArray As ArrayList, ByVal threadid As String)

        For i = 0 To TheProxyArray.Count - 1
            Try
                Dim Newproxy As String = TheProxyArray.Item(i).ToString
                Dim host As String = Newproxy.Remove(Newproxy.IndexOf(":"))
                Dim port As Integer = (Newproxy.Remove(0, (Newproxy.IndexOf(":") + ":".Length)))
                Dim PR As New Net.WebProxy(host, port)
                Dim URL As String = "https://offenceappeal.runescape.com/lang/en/aff/runescape/login.ws?username=Zezima&password=ImGay&dest=viewoffencehistory.ws"
                Dim Request As Net.WebRequest = Net.WebRequest.Create(URL)
                Dim Response As Net.WebResponse = Request.GetResponse
                Dim Reader As New IO.StreamReader(Response.GetResponseStream)
                tries = tries + 1
                Request.Timeout = Integer.Parse(TimeOutString)
                Request.Proxy = PR
                Source = Reader.ReadToEnd
                Reader.Close()
                Response.Close()
            Catch Exc As Net.WebException
                If (Source.IndexOf("Invalid Username or password" > -1)) Then
                    Status = "Working Proxy!"
                    WorkingArray.Add(TheProxyArray.Item(i))
                ElseIf (Source.IndexOf("Login Blocked" > -1)) Then
                    Status = "Working Proxy!"
                    WorkingArray.Add(TheProxyArray.Item(i))
                ElseIf (Source.IndexOf("You are logged in as" > -1)) Then
                    Status = "Working Proxy!"
                    WorkingArray.Add(TheProxyArray.Item(i))
                ElseIf (Source.IndexOf("Working" > -1)) Then
                    Status = "Working Proxy!"
                    WorkingArray.Add(TheProxyArray.Item(i))
                ElseIf (Source.IndexOf("" > -1)) Then
                    Status = "Bad Proxy Or Timed-Out or Not Compatible With RuneScape"
                End If
                Console.WriteLine("Thread #" + threadid + " Checking Proxy: " + TheProxyArray.Item(i) + " Result: " + Status)
            End Try
        Next i
        Console.WriteLine("Done Checking Proxies To See If They're Working!")
    End Sub
 
I don't know what the line numbers you posted means, but you set properties for Request variable after the webrequest has been submitted so it must be the "Request.Timeout =" line. It's too late to change the request at this time when it was submitted with your GetResponse call.
 
Back
Top