Click here to Skip to main content
15,898,371 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
I would like to hear some of your opinion and suggestions about what is the best way to keep auto refreshing web page or part of it with C# .NET. The idea is to make web auction and keep the bidders posted about the latest changes. I already have pooling solution with Update Panel and Timer tick event that refreshes the web page on small interval and requests the data from database all the time. This may be the most reliable solution but it may overload the server and cause slowdowns, timeouts or etc. Also I've been reading little about other reverse techniques, like Comet, but the example I've found worked only at IE. Any suggestions, examples or resources to read will help.
Thanks,
Posted
Comments
[no name] 8-Jun-11 17:17pm    
I don't know what the best way is, but I have good experience with update panels and timers.

I've build a narrowcasting application one year ago and used iframes, update panels and timers. It is a stable application that checks every 10 seconds for an alert (in case of an alarm it shows a special message), updates every iframe independent (only in case the content of the iframe was changed) and also refreshes the whole page once in a while when nothing changed for a certain period. It worked with IE6+ and Firefox, also on mobile devices. Only problem I encountered had to do with caching in IE.
Igor Jas 9-Jun-11 3:49am    
Ruard about the caching, if you use .NET, you may try add this line in Page_load method:

Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
Morl99 8-Jun-11 18:51pm    
Well you should check if anything really changed, and only update if it did (try checking against a changed_timestamp or something). While this does not reduce the number of requests to the server, it might decrease the overall workload for these requests. I also made good experiences with update panels and timers, in ASP.NET 4 this seems to be a reliable choice.
yesotaso 11-Jun-11 5:06am    
I dont have experience on web applications but I've read Push technology seems to be what you are looking for. Most probably you've read this aswell but if you google with keywords "server push" + some other relative words it might narrow down search window.

the following example shows how to refresh part in asp.net page every 0.5 second using asp.net ajax

XML
<form id="form1" runat="server">
 <div>
 <asp:ScriptManager ID="sm1" runat="server" />
 <asp:UpdatePanel runat="server" ID="up1">
 <ContentTemplate>
 <asp:Label ID="currentTime" runat="server" /><br />
 <asp:Timer runat="server" ID="refreshTimer" Interval="500" Enabled="true"
         ontick="refreshTimer_Tick" />
 </ContentTemplate>
 <Triggers>
 <asp:AsyncPostBackTrigger ControlID="refreshTimer" EventName="Tick" />
 </Triggers>
 </asp:UpdatePanel>
 </div>
 </form>




C#
protected void refreshTimer_Tick(object sender, EventArgs e)
      {
          currentTime.Text = DateTime.Now.ToLongTimeString();
      }
 
Share this answer
 
Comments
yesotaso 11-Jun-11 5:10am    
Quote from question: "I already have pooling(polling?) solution with Update Panel and Timer tick event that refreshes the web page on small interval and requests the data from database all the time."
<>>>>>>>>>>
 
Share this answer
 
What about refreshing only when a change has ocurred instead of using a timer?

Maybe you could take a look at the Observer Pattern? [^]

"The observer pattern (a subset of the publish/subscribe pattern) is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems."
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900