Timing Out

Discussion in 'C#' started by Erco21, Aug 30, 2010.

  1. Erco21

    Erco21 New Member

    Joined:
    Aug 30, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi!

    I made a simple username checker application, in which i provide a list of usernames, and it checks if they exist on a website

    First few valid users go okay, but after that, checker keeps timing out, and if i remove the username on which it started timing out, it will do normal till next error
    this is the code i got so far:
    Code:
     private bool CheckURL(string url)
            {
    
                CheckForIllegalCrossThreadCalls = false;
    
                Application.DoEvents();
    
                Uri urlCheck = new Uri(url);
    
                WebRequest request = WebRequest.Create(urlCheck);
                request.Timeout = 1500;
    
                WebResponse response;
                try
                {
                    //get URL web response
                    response = request.GetResponse();
                }
                catch (Exception)
                {
    
                    return false; //url does not exist
                }
    
                string responseURL = response.ResponseUri.ToString();
    
    
                Application.DoEvents();
                if (string.Compare(responseURL, urlCheck.ToString(), true) != 0) //it was redirected, check to see if redirected to error page
                    return !(responseURL.IndexOf("404.php") > -1 ||
                           responseURL.IndexOf("404.htm") > -1);
                else
                    return true; //everything okay
            }
    
            public void checker()
            {
    
    StreamWriter sw;
                CheckForIllegalCrossThreadCalls = false;
                foreach (String s in listBox1.Items)
                {
    
                        label1.Text = s;
                        if (CheckURL("Auth Page" + s + ".EXTENSION"))
                        {
    
    
                            sw = File.AppendText(Application.StartupPath + "/valid.txt");
                            sw.WriteLine(s);
                            sw.Flush();
                            sw.Close();
    
                            listBox2.Items.Add(s);
    
                    }
    
                }
            }
    
    I dont have a clue what this could be, so any help would be appreciated

    Thank you in advance!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice