Users Online

Last post 05-14-2008 3:32 PM by yasserzaid. 2 replies.

Sort Posts:

  • Users Online

    04-21-2008, 11:27 AM

    Hello All,

    On my website, I m using Forms Authentication against AD. This is working fine but the problem with this, i cant see the UserID (real ids) in the eventvwr to find who is using the website?

    All i find is the Anonymous userid. Is there any way to find real ids ?

    REgards

     

  • Re: Users Online

    04-22-2008, 10:57 AM

    Any COMMENTS!!!!!!

  • Re: Users Online

    05-14-2008, 3:32 PM

    try this

     

    <%@ Page Language="C#" MasterPageFile="~/MasterPage/AdminMasterPage.master" AutoEventWireup="true" CodeFile="WhoIsOnline.aspx.cs" Inherits="Admin_WhoIsOnline" Title="Untitled Page" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <br />
        <strong>
        There are </strong>
        <asp:Label ID="lblSessionCount" runat="server" Style="position: static" Font-Bold="True"></asp:Label><strong>
        online users now</strong><br />
        <br />
        <asp:GridView ID="OnlineUserList" runat="server" AutoGenerateColumns="False" CellPadding="4"
                ForeColor="#333333" GridLines="None">
                <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:BoundField DataField="UserName" HeaderText="User Name" />
                    <asp:CheckBoxField DataField="IsOnline" HeaderText="Is Online" />
                    <asp:CheckBoxField DataField="IsApproved" HeaderText="Is Active" />
                    <asp:BoundField DataField="Email" HeaderText="Email" />
                </Columns>
                <RowStyle BackColor="#EFF3FB" />
                <EditRowStyle BackColor="#2461BF" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            <EmptyDataTemplate>
                No User Online now
            </EmptyDataTemplate>
            </asp:GridView>
    
    </asp:Content>

     and in code behind

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    
    public partial class Admin_WhoIsOnline : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            MembershipUserCollection OnlineUsers = new MembershipUserCollection();
            MembershipUserCollection AllUsers = new MembershipUserCollection();
            AllUsers = Membership.GetAllUsers();
    
            foreach (MembershipUser user in AllUsers)
            {
                if (user.IsOnline)
                {
                    OnlineUsers.Add(user);
    
                }
            }
            int OnlineUserCount = OnlineUsers.Count;
    
            lblSessionCount.Text = OnlineUserCount.ToString();
    
            OnlineUserList.DataSource = OnlineUsers;
            OnlineUserList.DataBind(); 
        }
    
        
    }
    
     
    Regards,
    Yasser Zaid

    ~ Please remember to click Mark as Answer on this post if it helped you ~
Page 1 of 1 (3 items)