I am using asp.net to develop a website, and I want one of my web pages to refresh every 5 seconds when requested; how can I achieve that?
Can you add a meta
tag to the page's header?
From wikipedia:
Place inside to refresh page after 5 seconds:
<meta http-equiv="refresh" content="5" />
Redirect to http://example.com/ after 5 seconds:
<meta http-equiv="refresh" content="5;url=http://example.com/" />
Redirect to http://example.com/ immediately:
<meta http-equiv="refresh" content="0;url=http://example.com/" />
Also see w3schools
Here is the tag for the meta refresh:
<meta http-equiv="refresh" content="5" />
Like ongle, I would suggest:
<meta http-equiv="refresh" content="5">
It should be noted that if your page is a largeish one, people on slow connections may never finish downloading the page before it refreshes.
If it is a large page and this is a concern, consider using JavaScript.
Placing this before the closing </body>
tag should do the trick:
<script>setTimeout('window.location.href = window.location.href', 5000);</script>
Given that much of your page may not change, you may want to consider an AJAX panel for that, given that ASP.NET supports it.
Check out the tutorial
You could just use a meta tag or javascript as other suggested, but be careful when doing that. If you do it wrong you can break your viewstate. A better option might be to use the timer control and do a postback from there.