How to redirect one page to another page after specify time in ASP.Net C#

In the previous project I need to redirect the page after 10 sec. we have learn about how to redirect to another page after some time in asp.net c#. We can get with some below methods .
Method1:-
HTML Refresh Meta Tags
Below method is easiest way to redirect one page to another page. We just need to add this method on header of the page
Source Code:-

<head runat="server">
    <title> HTML Refresh Meta Tags</title>
    <meta http-equiv="Refresh" content="10;url=Page2.aspx" />

</head>

Method2:-
Meta Tag using HtmlMeta class in code behind(c#)
Below method, we can use this on code behind and we can also use with other functionality and methods
Namespace:-
using System.Web.UI.HtmlControls;
Code Behind(c#):-
protected void Button1_Click(object sender, EventArgs e)
{
    HtmlMeta meta = new HtmlMeta();
    meta.HttpEquiv = "Refresh";
    meta.Content = "10;url=Page2.aspx";
    this.Page.Controls.Add(meta);
    Label1.Text = "You will be redirected on Page2.aspx in 10 seconds";
}

Method:-3
Meta Tag by added Response Header
Below method, Meta tag is added to the page using the Http Response header.
protected void Button1_Click(object sender, EventArgs e)

{
   Response.AppendHeader("Refresh", "10;url=Page2.aspx");
   Label1.Text = "You will be redirected on Page2.aspx in 10 seconds";

}
How to redirect one page to another page after specify time in ASP.Net C# How to redirect one page to another page after specify time in ASP.Net C# Reviewed by NEERAJ SRIVASTAVA on 6:01:00 PM Rating: 5

1 comment:

Powered by Blogger.