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

  • Home
  • SEARCH
  • 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 6005467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:24:04+00:00 2026-05-23T01:24:04+00:00

I know this question has been answered before in this thread , but I

  • 0

I know this question has been answered before in this thread, but I couldn’t seem to find the details.

In my scenario, I am building a console application which will keep an eye on html page source for any changes. If any update/change occurs, I will perform further operations. Moreover, I’ll also perform a request after every 1 second, or as soon as the previous request finishes.

I can’t seem to figure out should I use HttpWebRequest or WebClient for downloading the html page source and perform comparison? What do you think would be an ideal solution in my case? Speed and reliability both 🙂

  • 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-23T01:24:05+00:00Added an answer on May 23, 2026 at 1:24 am

    I’d go with HttpWebRequst because it’s not as abstracted and lets you fiddle with HTTP params quite a bit. It gives you the option to not download the entire page if the server returns “file not changed”, for example.

    If you add some parameters to your request like IfModifiedSince (it might be HEAD or GET request) the server may return the response code 304 – NOT MODIFIED. Refer to description of caching in HTTP for further explanation.

    The point is to make sure that you only download the full page when it’s actually modified since the last time you fetched it. Most of the time it won’t be changed (I suppose, can’t know for sure without knowing your domain), so you only need to get a lightweight response from server which simply states “nothing changed here”.

    Update: code sample demonstrating the use of IfModifiedSince property:

    bool IsResourceModified(string url, DateTime dateTime) {            
        try {
            var request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
            request.IfModifiedSince = dateTime;
            request.Method = "HEAD";
            var response = (HttpWebResponse)request.GetResponse();
    
            return true;
        }
        catch(WebException ex) {
            if(ex.Status != WebExceptionStatus.ProtocolError)
                throw;
    
            var response = (HttpWebResponse)ex.Response;
            if(response.StatusCode != HttpStatusCode.NotModified)
                throw;
    
            return false;    
        }
    }
    

    This method should return true if the page was modifed since the dateTime date and false if it wasn’t. GetResponse method will throw a WebException if you make a HEAD-request and the server returns 304 – NOT MODIFIED (which is kinda unfortunate). We have to make sure that it’s not some other web connection problem, that’s why I check the status of web exception and the HTTP status in response. If anything else caused an exception we just throw it further.

    Console.WriteLine(IsResourceModified("http://example.com", new DateTime(2009)));
    Console.WriteLine(IsResourceModified("http://example.com", DateTime.Now));
    

    This sample code produces the output:

    True
    False
    

    Note: make sure to read Jim Mischel’s addition to this answer as he gives few good advices on this technique.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this question has been asked before, but many answers don't give clear
So this question has been asked before , but not answered in great detail.
I know a similar question has been answered before here , but I just
I know this question has been asked before and I read all the answers
Forgive me if this has been asked before; I did a search but couldn't
First off, let me start by saying, I know this exact question has been
I have an odd question that im not sure has been asked/answered, and im
Disclaimer: This is a follow-on question from my other question about NServiceBus which was
Coming from a Java background, this is the way I'm thinking: The server provides
I've never used source control before (always used renaming files and other methods), so

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.