Home Asp.net Auto-refresh Webpage in Every 10 Seconds in Asp.net C# Vb.net

Auto-refresh Webpage in Every 10 Seconds in Asp.net C# Vb.net

150
0
Redirect Page on Button Click

Now here in this tutorial, I’ll explain how to auto refresh webpage in every 10 seconds or any specific time intervals using meta tag in asp.net c# or vb.net.If you feel this tutorial is upto the mark, then kindly check out our other tutorials. We ensure you that those tutorials will be as amazing as this one.

In my previous tutorials, I’d explained how to automatically redirect to a specific url in 10 seconds, how to redirect to a specified url or webpage on button click, gridview inline insert update delete and other more cracking tutorials on Asp.net, JavaScript, jQuery here.

We can do this by using simple one line of html code, by using html meta tag.

<meta http-equiv="refresh" content="10;" />
Note: You just need to place above single line of code in html head tag. Here 10 in content=”10;” is a time duration in seconds, you can freely change as per your need. If you want to redirect user to a specific url or webpage, check this post.

Auto-refresh Webpage – [.aspx]

Following is the complete HTML Markup code that I used for the demonstration:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="refresh" content="10;" />
    <title>Auto Refresh Webpage in every 10 seconds</title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <br />
            <br />
            <h3>Wait for 10 seconds and look at your web browsers tab, 
                It'll auto refresh page in every 10 seconds</h3>
        </div>
    </form>
</body>
</html>

If you want to implement this functionality from code-behind, it’s also as simple as like that. Simply add the following line of code on Page_Load and ignore the above example.

Auto-refresh Webpage Using C# – [.cs]

If you’re using C#, use following code-behind statement to refresh webpage automatically:

Response.AppendHeader("Refresh", "10");

Auto-refresh Webpage Using Vb.net – [.vb]

If you’re using Vb.net, use following code-behind statement to refresh webpage automatically:

Response.AppendHeader("Refresh", "10")

Download Example

Git Repo

That’s it, by using this way you can automatically refresh any html or asp.net web page url after N seconds. In above example, I’ve used 10 seconds but you can change it to any number you want.

Let me know if you’ve any questions or doubts about this tutorial by writing down your queries in comment below. I would be happy to provide you my feedback as soon as possible.

Happy coding!

Previous articleWhat is the difference between String and StringBuilder in Asp.net C# Vb.net?
Next articleAutomatically Redirect a Web Page or URL after 5 Seconds in Asp.net
Hi there, I am Mayank, the man behind Technical Mack. I started AspnetO with a motive to educate people on various programming languages ranging from beginners to expert level. Through this blog, I aim to provide more insightful content.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

5 × 5 =