redirect a page automatically redirect a page automatically asp.net asp.net

redirect a page automatically


You can use something like this:

<meta http-equiv="Refresh" content="60; url=http://your.new/url/here" />

The "60" is the time in seconds to wait before page redirect.


Try this one line code:Here 5 means redirecting after 5 seconds, and make it 60 if you want to redirect after 1 minute.

protected void btnRedirect_Click(object sender, EventArgs e)  {      Response.AddHeader("REFRESH", "5;URL=YourNextPage.aspx");  }

This code you can also put in Load event of the page so that it'll redirect to another page after loading current page.


You cannot use C# code to redirect after a certain time from the server side, since C# is executed on server side. You can do this by having the meta tag in your HTML:

<meta http-equiv="refresh" content="300; url=newlocation">

You can write code in C# to create this tag, Here is an example:

HtmlMeta meta = new HtmlMeta();  HtmlHead head = (HtmlHead)Page.Header;meta.HttpEquiv= "refresh";meta.Content = "300; url=newlocation";head.Controls.Add(meta);