I need to keep a list of logged users STATUSES at the Server level (either “ONLINE” or “OFFLINE”).
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.
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.
QUESTIONS:
- How can I create an AutoRefresh call that fires every XX seconds
- How can I ensure this call executes only when I’m in ONLINE status
Thanks in advance.
This is the Partial View in question.
Where do you suggest I put the code to run the AutoRefresh (MasterPage, Main View, Partial View) ???
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%
if (MySite.Security.SiteUser.IsAuthenticated)
{
if (Convert.ToBoolean(ViewData["IsLogged"]))
{
%>
<div id="onlineStatus">
You are currently ONLINE >>
<%: Html.ActionLink("Take a Break", "GoOffline", "Account")%>
</div>
<%
}
else
{
%>
<div id="offlineStatus">
Ready for business >>
<%: Html.ActionLink("Go Online", "GoOnline", "Account")%>
</div>
<%
}
}
%>
Both of you put me on the right direction and the final “working” answer is: