Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / May 2005

Tip: Looking for answers? Try searching our database.

does HttpWebResponse.StatusCode download the entire requested page

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomasamillergoogle@yahoo.com - 15 May 2005 22:30 GMT
Hello, I have build a function that checks an internet connection (see
below)

Is there a way to do this so the entire CheckConnection.htm page is not
downloaded? I only want to get the "OK" response without getting the
entire file.

              public static bool IsConnected()
        {
            HttpWebRequest webreq;
            HttpWebResponse webresp;

            string strurl = "http://www.blah.com/blah/CheckConnection.htm";
            bool bConnected = false;
            try
            {
                webreq = (HttpWebRequest) WebRequest.Create(strurl);
                webresp = (HttpWebResponse) webreq.GetResponse();
                if (webresp.StatusCode == HttpStatusCode.OK)
                {
                    bConnected = true;
                }
                else
                {
                    bConnected = false;
                }
                return bConnected;
            }
            catch (Exception e)
            {
                string msg =(e.Message);
                if (msg ==""){}
                bConnected = false;
                return bConnected;
            }
            finally
            {
                webresp = null;
            }

        }
Chad Z. Hower aka Kudzu - 16 May 2005 07:41 GMT
> Is there a way to do this so the entire CheckConnection.htm page is not
> downloaded? I only want to get the "OK" response without getting the
> entire file.

You can issue a HEAD command instead of a GET.

--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
     "Programming is an art form that fights back"

Blog: http://blogs.atozed.com/kudzu

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.