Create Auto Refresh Page Or Redirect After A Given Seconds
Posted by in Tips And Tricks March 22, 2012 Leave a comment

Simply add a HTML meta between and to automatically refresh the current page or redirect to another website url after a given seconds.

1. HTML Meta Auto Refresh

Auto refresh the current page after 60 seconds (1 minute):

<meta http-equiv="refresh" content="60" />

2. HTML Meta Auto Redirect

Auto redirect to after 5 seconds:

<meta http-equiv="refresh" content="5;" />

3. Example

An aspx source file below will display current time and it will be updated after 5 seconds:

+ aspx file:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="auto-refresh-page-after-a-given-seconds.aspx.cs" Inherits="auto_refresh_page_after_a_given_seconds" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <title>Demo Automatically Refresh Current Page After 5 Seconds</title>
    <meta http-equiv="refresh" content="5" />
    <form id="form1" runat="server">
    Current Time: <asp:Label runat="server" ID="lblCurrentTime" ForeColor="Blue"></asp:Label>

+ aspx.cs file:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class auto_refresh_page_after_a_given_seconds : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
        lblCurrentTime.Text = DateTime.Now.ToLongTimeString();

Hoan Huynh is the founder and head of Reach him at