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;" />
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!