Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1109237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:12:04+00:00 2026-05-17T02:12:04+00:00

I have a function called GetIP which I call on startup and when the

  • 0

I have a function called GetIP which I call on startup and when the user presses a button.
for some reason it does not crash on startup, but it does when calling the function with a button. No exeptions nothing it just freezes.

code for function :

        private void GetIP()
        {
        string pageTitle = functions.GetWebPageTitle("http://xyro18.woelmuis.nl/index.php");
        string[] ip = new string[2];
        ip = pageTitle.Split('|');
        currentIpLabel.Text = ip[0];
        webIpLabel.Text = ip[1];
        }

Now I found out that it crashes in my getWebPageTitle function

code for function :

public static string GetWebPageTitle(string url)
    {
        // Create a request to the url
        HttpWebRequest request = HttpWebRequest.Create(url) as HttpWebRequest;
        request.Method = "HEAD";
        // If the request wasn't an HTTP request (like a file), ignore it
        if (request == null) return null;

        // Use the user's credentials
        request.UseDefaultCredentials = true;

        // Obtain a response from the server, if there was an error, return nothing
        HttpWebResponse response = null;
        try { response = request.GetResponse() as HttpWebResponse; }
        catch (WebException) { return null; }

        // Regular expression for an HTML title
        string regex = @"(?<=<title.*>)([\s\S]*)(?=</title>)";

        // If the correct HTML header exists for HTML text, continue
        if (new List<string>(response.Headers.AllKeys).Contains("Content-Type"))
            if (response.Headers["Content-Type"].StartsWith("text/html"))
            {
                // Download the page
                WebClient web = new WebClient();
                web.UseDefaultCredentials = true;
                string page = web.DownloadString(url);

                // Extract the title
                Regex ex = new Regex(regex, RegexOptions.IgnoreCase);
                return ex.Match(page).Value.Trim();
            }

        // Not a valid HTML page
        return null;
    }

It crashes on the web.DownloadString

with crash I mean freeze and does not display any exeptions etc.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:12:05+00:00Added an answer on May 17, 2026 at 2:12 am

    Well, I can’t say I know why it freezes, but here are some suggestions that may help:

    • Call response.Close() when you’re done with it (e.g. when you return from the method).
    • The WebClient class implements IDisposable, so you should try the using construct.
    • Instead of creating a new Regex object every time for a single match, use the static methods in the Regex class.
    • Try setting the web.Proxy property to null, to make sure that it doesn’t try to detect a proxy (as it would by default).
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function called PreProcessSource, which allocates a boost::wave::context and does some preprocessing;
I have a function called goRight() which does some stuff when I click a
Let's say I have a function called DisplayWhiskers() which puts some slashes and backslashes
I have function called buildRay which returns a 1x4 matrix. I call it multiple
I have a function called call facebook. call_facebook(284328420994); call_facebook(197214710347172); It runs severaltimes It makes
I am using jQuery(Latest release) and have a function called calculate() which gets called
Now I'm sure this is super easy, I have a function called remove_deposit which
I have below a javascript function which gets called on click of two separate
I have a function called listelements() , which outputs text like <li>text1</li><li>text2</li> . I
I have a function called processXML on the timeline (yes, I know now...) which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.