RE: Best way to monitor online user activity?
- From: Saubz <saubz@xxxxxxxxxxxxxxxxx>
- Date: Fri, 8 Dec 2006 07:25:01 -0800
Thanks for the reply, Steven. That was very helpful. I have a couple
questions.
First, how would you get the user information during
application.BeginRequest? I've tried using these:
HttpContext.Current.User.Identity.Name.ToString()
application.User.Identity.Name.ToString()
and they both throw exceptions.
Second, what would be the 'best practice' for storing the user activity
logged by this module to be accessed from another page? In a database or
other means?
Thanks again for your help!
"Steven Cheng[MSFT]" wrote:
Hello Matt,.
Do you mean you want to create a profile component that will log all the
requests from each client users(to certain pages in the application)?
Based on my experience, since you want to capture both the user identiy
info and the page they're requesting, and also need to separate this
profile logic from normal page code logic, I think using a custom
HttpModule should be a good approach.
Each page request arrive at IIS and ASP.NET runtime will be processed by an
HttpApplication pipeline, and at the begining of the pipeline, there are
series of httpModules that will do some preprocessing before the final
handler that process the request. e.g. you can find those predefined
built-in httpmodules in the global web.config(or machine.config for .net
1.1):
#each module is used for a certain service(such as SessionState,
OutputCache, FormsAuth....)
=============================
<httpModules>
<add name="OutputCache"
type="System.Web.Caching.OutputCacheModule" />
<add name="Session"
type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication"
type="System.Web.Security.WindowsAuthenticationModule" />
<add name="FormsAuthentication"
type="System.Web.Security.FormsAuthenticationModule" />
<add name="PassportAuthentication"
type="System.Web.Security.PassportAuthenticationModule" />
<add name="RoleManager"
type="System.Web.Security.RoleManagerModule" />
<add name="UrlAuthorization"
type="System.Web.Security.UrlAuthorizationModule" />
<add name="FileAuthorization"
type="System.Web.Security.FileAuthorizationModule" />
<add name="AnonymousIdentification"
type="System.Web.Security.AnonymousIdentificationModule" />
<add name="Profile" type="System.Web.Profile.ProfileModule" />
<add name="ErrorHandlerModule"
type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</httpModules>
===============================
For your scenario, you want to get the client user identity info and
session info, you can create a custom httpmodule and configure it behind
those built-in module. And in custom httpmodule code, you can hook the
certain global event you want(see below msdn reference) and add the tracing
and logging code there(you can easily get the requested path, or other
client user info there also)
#How To Create an ASP.NET HTTP Module Using Visual C# .NET
http://support.microsoft.com/kb/307996/en-us
#How to: Create Custom HTTP Modules
http://msdn2.microsoft.com/en-us/library/ms227673.aspx
Here is also a msdn reference introducing the ASP.ENT application's
application life cycle:
#ASP.NET Application Life Cycle Overview
http://msdn2.microsoft.com/en-us/library/ms178473.aspx
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- RE: Best way to monitor online user activity?
- From: Steven Cheng[MSFT]
- RE: Best way to monitor online user activity?
- References:
- RE: Best way to monitor online user activity?
- From: Steven Cheng[MSFT]
- RE: Best way to monitor online user activity?
- Prev by Date: Re: How to get Previous Page name?
- Next by Date: Re: Problem sending email to address of different domain
- Previous by thread: RE: Best way to monitor online user activity?
- Next by thread: RE: Best way to monitor online user activity?
- Index(es):
Relevant Pages
|