You are currently browsing the category archive for the 'ASP.NET Timed Page Refresh With Assigned URL' category.

Objective: This short article describes via example, how to refresh an asp.net page after a certain number of seconds to itself or to another URL.

Background: In my applications I often need to display a page for a certain number of seconds and then redirect either back to the previous page or to a different URL. This is a very simple procedure and hopefully will save some time to some.

Procedure: Follow instructions below to accomplish this task. This article uses Visual Web Developer Express 2008.

  1. Copy and paste the following code into a page load event within your script block or code behind page.

    '.......................ASP.NET Page Refresh Start.........................
    'when the page loads
    'refresh the page after number (3) of seconds to the URL assigned
    'end subprocedure
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        Response.AddHeader("Refresh", "3;URL=http://www.google.com/")
    End Sub
    '.......................ASP.NET Page Refresh End.........................

  2. You can set the number of seconds after which the refresh will execute. In the code above it is set for 3 seconds and then redirects to google.com. Make your changes and enjoy!