Click here to Skip to main content
15,886,857 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
hi,

how can i get the live user that are currently using my asp.net web application.Thanks in Advance

Thanks
Touqeer hameed
touqeer.hameed@gmail.com
Posted

1 solution

use ASP.NET member ship system to manage the user accounts.You can use the below SP to fetch who are online.

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

-- =============================================
-- Author: <author,,name>
-- Create date: <create date,,="">
-- Description: <description,,>
-- =============================================
ALTER PROCEDURE

[dbo].[usp_GetCurrentActivityForOnlineUsers]
(
@MinutesSinceLastInactive int
)
AS
DECLARE @CurrentTimeUtc datetime
SET @CurrentTimeUtc = getutcdate()
DECLARE @DateActive datetime
SELECT @DateActive = DATEADD(minute, -(@MinutesSinceLastInactive), @CurrentTimeUtc)
SELECT act.UserId,
u.UserName,
act.Activity,
act.PageUrl,
act.ActivityDate,
@CurrentTimeUtc as CurrentDate
FROM dbo.aspnet_Users u(NOLOCK)
INNER JOIN dbo.ActivityLog act(NOLOCK) ON
act.UserId = u.UserId
WHERE u.LastActivityDate > @DateActive AND
act.ActivityDate = u.LastActivityDate
ORDER BY act.ActivityDate DESC
 
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