programmatically refresh/reload web page

I have a C# application that produces web pages on a windows PC. This output is either viewed on the PC via a browser or the image is scraped and sent to a display board.
What I want to be able to do is cause a reload of the webpage after I update it without any user input.

Originally I just had the page refresh itself every x seconds.
This worked until the reload coincided with the update at which point you would get a "page not found" error that would never clear.

Currently I have the page as a frame inside an outer page. The outer page does nothing but call a reload every x seconds. This takes care of the "page not found" error as when this occurs in the internal page, the next refresh of the external page reloads it. If however, the user needs to scroll the page or read the tooltips, the reload is incredibly frustrating.

What I want to be able to do is only reload the page if the page and or .css file is updated. As I can find when this happens via the application that produces the page (and has a built in .css editor), I just need an API call to force the reload from an external source.

Currently I can only use Firefox as a browser due to the "flash" from Chrome during a reload. IE has never been a contender due to many issues.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Paul MacDonaldDirector, Information SystemsCommented:
AJAX is your friend.  Whether you want to reload just a single element, or reload the whole page.  it's also possible to reload only on some backend change.
jetbetAuthor Commented:
So by the look of it I could possibly add 2 non-visual elements say currentDateTime and newDateTime to a page.
When my application creates the new page I write to a text file with Datetime.Now formatted as it is on the page.

I also run a timer to run an Ajax command every 2 seconds say to do the following
Copy the contents of the text file to the newDateTime element and compare to the currentDateTime element.
If the newDateTime does not equal the currentDateTime I reload the page.

As the new page is always created with the 2 DateTime elements equal and I refresh the text file with the same DateTime as the newly created page, this should reload the page only when it has changed.

Does this sound like the correct approach?

I have not used AJAX before and before I try to code this it would be good to know I am heading in the right direction.
Paul MacDonaldDirector, Information SystemsCommented:
Not knowing how your site is running, it's difficult to say if this the best approach, but it's certainly an approach.

Rather than write to a text file, you might consider storing the "LastUpdate" value as a session variable on the server.  Then the javascript can query the server for that value (every two seconds, as you say) and compare it to the "PageCreated" value embedded in the page.  If the two are different, reload the dynamic content.  Something like that might save you some hassle.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

jetbetAuthor Commented:
The "site" as stated above is just a Windows PC running a C# application that produces a web page that is stored on the PC.
The page is not sent anywhere I just need a way to force the reload after it has been updated.

I am not sure what you mean by storing the value as a session variable but will look for an example of Javascript doing a query for it.
Paul MacDonaldDirector, Information SystemsCommented:
Okay, so the C# app generates a page, and you want the page to reload itself when that source is updated.  I get it now.

I would load the page, then store the current time in the page somewhere - either in a javascript variable or in a hidden variable in the page.
Then, every two seconds, check the last write time of the hard drive copy of the page using some javascript, and reload the page if the page on the hard drive is newer than the page in the browser.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jetbetAuthor Commented:
Thanks for your help
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.