RE: Best way to monitor online user activity?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



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.



.



Relevant Pages

  • RE: Web Service migration question
    ... Custom classes built from XSD. ... both WS and Client sides using these objects. ... instance of the Request object and prior to invoking WS I save request to XML ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.xml)
  • RE: Best way to monitor online user activity?
    ... HttpModule should be a good approach. ... handler that process the request. ... you can create a custom httpmodule and configure it behind ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.aspnet)
  • RE: Roles based Forms Auth - denied pages redirect
    ... but figured that an HttpModule would be the only possible way. ... redirect to a custom page - from which I could tell the user they are not ... >Shaun Venus ... >> have to write such code and lookup web.config files for each request (I ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • RE: shorten the page address
    ... When the IIS receive a request which doesn't have a valid server document ... configure the IIS to use a custom 404 error page. ... So for the following redirect case: ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.inetserver.asp.general)
  • Whats in in the block git tree for 2.6.28?
    ... Support for handling online resizing of block devices. ... Adds block layer support for the 'discard' operation, ... By dropping it we can also shrink request ...
    (Linux-Kernel)