Monday, 1 June 2015

Automatic Page Refresh in ASP.NET

To refresh a page automatically at a time interval. Doing this is pretty simple, using META tags.

    <meta http-equiv="refresh" content="45">


    <meta http-equiv="refresh" content="45;url=home.aspx">

But if you used Master Pages, the META tag then all pages that use this master page will be refreshed, which is not desired, to accomplish this, add the following c# code in the code behind of, the particular page you want to refresh:
Response.AppendHeader("Refresh", 45 + "; URL=home.aspx");

Where, 45 is the time interval in seconds.

There are many other ways of doing auto refreshing , like using JavaScript and J Queries, but this is simplest way.