title: MVC Partial View with AutoRefresh
body: <p>I need to keep a list of logged users STATUSES at the Server level (either "ONLINE" or "OFFLINE").</p>
  
  <p>So I wrote a Partial View to maintain the user current Status (Online, Offline). 
  The server stores these values both on the Database and all the current Online users also in a Cached entry so that I can retrieve the list of all current "Online" users from cache.</p>
  
  <p>In order to keep this list uptodate, I now need an asynchronous AutoRefresh call that notifies the server to keep my userID on the ONLINE list. This call should execute every xx seconds and should only execute if the current status is ONLINE.</p>
  
  <p>QUESTIONS:</p>
  
  <ol>
  <li>How can I create an AutoRefresh call that fires every XX seconds</li>
  <li>How can I ensure this call executes only when I'm in ONLINE status </li>
  </ol>
  
  <p>Thanks in advance. </p>
  
  <hr>
  
  <p>This is the Partial View in question.
  Where do you suggest I put the code to run the AutoRefresh (MasterPage, Main View, Partial View) ???</p>
  
  <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %&gt;
  
  &lt;%  
      if (MySite.Security.SiteUser.IsAuthenticated)
      {
          if (Convert.ToBoolean(ViewData["IsLogged"]))
          {
          %&gt;
              &lt;div id="onlineStatus"&gt;                
                  You are currently ONLINE &gt;&gt;
                  &lt;%: Html.ActionLink("Take a Break", "GoOffline", "Account")%&gt;
              &lt;/div&gt;
          &lt;%
          }
          else
          { 
          %&gt;
              &lt;div id="offlineStatus"&gt;
              Ready for business &gt;&gt;
                  &lt;%: Html.ActionLink("Go Online", "GoOnline", "Account")%&gt;
              &lt;/div&gt;
          &lt;%
          }
      }
  %&gt;
  </code></pre>