Site Statistics

Discussion in 'ASP .Net' started by Paps, Nov 24, 2003.

  1. Paps

    Paps Guest

    I build a class for implementing site access statistics but I cannot track
    for html pages, how can do this ?

    thanks
    Paps
    Paps, Nov 24, 2003
    #1
    1. Advertising

  2. Hi Paps,

    Based on your brief description on your concern, I am not sure whether I
    did understand you.

    However, based on my experience, it seems that you should associate the
    html files with the aspnet_isapi.dll ISAPI, as what aspx files or others
    do. As a sequence, all the html files will also be transferred to aspnet_wp
    worker process for processing.

    You can do it by adding an Application Mappings via Internet Information
    Service Management console.

    Please let me know it hits what you are looking for.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 25, 2003
    #2
    1. Advertising

  3. Paps

    Paps Guest

    Hi Jacob

    I'm doing the site statistics to record when a page (htm or aspx) is
    visited.
    On the aspx pages there isn't problem that i found on the htm's one.
    To solve the problem i associated the htm extension to the ASP.NET framework
    from inside IIS and i build an HttpModule to trap any request before .NET
    process it, of course i modify the web.config file in the httpmodule
    section.

    At this point of work some times the htm pages are logged but sometimes they
    aren't (maybe 4 cache even if all page's of my site expire immediatly??).

    What can i do ?

    //////////// *************** My custom http module

    public class MyHttpModule : IHttpModule
    {
    public String ModuleName { get { return "My Module"; } }

    public void Init(HttpApplication application) {
    application.PreRequestHandlerExecute += (new
    EventHandler(this.Application_PreRequestHandlerExecute)); }

    protected void Application_PreRequestHandlerExecute (Object source,
    EventArgs e) {
    HttpApplication application = (HttpApplication)source;
    HttpContext Context = application.Context;
    if (Context.Session!=null) {
    if (Context.Session["Stats"]!=null) {
    EOLStatistics Stats = (MyStatistics)Context.Session["Stats"];
    Stats.AddPage(Context.Request.Url.ToString()); }
    }
    }
    public void Dispose()
    {
    }
    }

    ///*****************************************

    if you want i can post some other little part of code.

    thank's
    Paps



    "Jacob Yang [MSFT]" <> wrote in message
    news:...
    > Hi Paps,
    >
    > Based on your brief description on your concern, I am not sure whether I
    > did understand you.
    >
    > However, based on my experience, it seems that you should associate the
    > html files with the aspnet_isapi.dll ISAPI, as what aspx files or others
    > do. As a sequence, all the html files will also be transferred to

    aspnet_wp
    > worker process for processing.
    >
    > You can do it by adding an Application Mappings via Internet Information
    > Service Management console.
    >
    > Please let me know it hits what you are looking for.
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    Paps, Nov 25, 2003
    #3
  4. Hi Paps,

    Thank you for your update.

    Is it possible for you to provide a simple testing sample and tell me how
    to reproduce the problem on my side step by step? It will be very helpful
    to this issue. I certainly appreciate your time.

    My Email address is . Please use the title - "20076723
    - microsoft.public.dotnet.framework.aspnet".

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 26, 2003
    #4
  5. Paps

    Paps Guest

    Ok Jacob.

    Create a Simple WebApplication1 Project and add to it's solution a new class
    library project (the MyHttpModule) add to the WebApplication1 references a
    reference to the MyHttpModule project.
    Add to the Web.config file a reference to the dll (see below)
    Add to the WebApplication1 project two htm pages called test1.htm and
    test2.htm, copy the following codes for each pages and try it.
    The call to the module for the aspx page work always but to the htm page
    work only the first time or only when you refresh it

    I'm using IE 6 with (menu--> tools --> internet options --> Settings -->
    Every visit to this page "checked")
    IIS 5.1 with application mapping for 'htm' pages in the Default web site to
    (C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_isapi.dll)

    //*********** HttpModuleClass
    using System;
    using System.Web;
    namespace MyHttpModule
    { public class MyHttpModuleClass : IHttpModule {
    public MyHttpModuleClass(){}
    public void Init(HttpApplication application) {
    application.PreRequestHandlerExecute += (new
    EventHandler(this.Application_PreRequestHandlerExecute));
    }
    protected void Application_PreRequestHandlerExecute (Object source,
    EventArgs e){
    HttpContext Context = ((HttpApplication)source).Context;
    if (Context.Session!=null){
    if (Context.Session["nPageCalled"]!=null)
    Context.Session["nPageCalled"]=
    ((int)(Context.Session["nPageCalled"]))+1;
    else
    Context.Session["nPageCalled"]= 1;
    Context.Response.Write("<br><br><br><br><h2><font color=red>My Module
    Called "+Context.Session["nPageCalled"]+"</font></h2>");
    }
    }
    public void Dispose() {}
    }
    }

    //*********** HttpModuleClass END
    //************ WebForm1.aspx
    <body MS_POSITIONING="GridLayout">
    <form id="Form1" method="post" runat="server">
    <asp:HyperLink id="HyperLink1" style="Z-INDEX: 101; LEFT: 20px; POSITION:
    absolute; TOP: 9px" runat="server"
    NavigateUrl="test1.htm">Test1</asp:HyperLink>
    <asp:HyperLink id="HyperLink2" style="Z-INDEX: 102; LEFT: 117px;
    POSITION: absolute; TOP: 8px"
    runat="server" NavigateUrl="test2.htm">Test2</asp:HyperLink>
    </form>
    </body>

    //************ WebForm1.aspx END
    //************ Test1.htm AND Test2.htm
    <head>
    <META HTTP-EQUIV="expires" CONTENT="Thu, 27 Jun 1980 10:56:57 GMT">
    <META HTTP-EQUIV="cache-control" CONTENT="no-cache">
    </head>
    <body>
    <a href="WebForm1.aspx">Go Back</a>
    </body>

    //************ Test1.htm AND Test2.htm END
    //************ WEB.CONFIG
    <httpModules>
    <add name="MyHttpModule" type="MyHttpModule.MyHttpModuleClass,
    MyHttpModule" />
    </httpModules>

    //************ WEB.CONFIG END


    Hope this help you to reproduce the problem

    let me know
    Paps


    "Jacob Yang [MSFT]" <> wrote in message
    news:zrgh8T%...
    > Hi Paps,
    >
    > Thank you for your update.
    >
    > Is it possible for you to provide a simple testing sample and tell me how
    > to reproduce the problem on my side step by step? It will be very helpful
    > to this issue. I certainly appreciate your time.
    >
    > My Email address is . Please use the title - "20076723
    > - microsoft.public.dotnet.framework.aspnet".
    >
    > Best regards,
    >
    > Jacob Yang
    > Microsoft Online Partner Support
    > Get Secure! ¨C www.microsoft.com/security
    > This posting is provided "as is" with no warranties and confers no rights.
    >
    Paps, Nov 26, 2003
    #5
  6. Hi Paps,

    Thank you for your update.

    Have you mapped all HTTP requests for files with file name extension .htm
    to the class System.Web.UI.PageHandlerFactory and for HTTP GET and HTTP
    HEAD requests for files with file name extension in web.config or
    machine.config file? For example,

    <httpHandlers>
    <add verb="*" path="*.htm" type="System.Web.UI.PageHandlerFactory"/>
    ¡­¡­
    </httpHandlers>

    Please change it accordingly and let me know if the problem still persists.

    Best regards,

    Jacob Yang
    Microsoft Online Partner Support
    Get Secure! ¨C www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jacob Yang [MSFT], Nov 27, 2003
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr Newbie

    Site Statistics - Need Display Package

    Mr Newbie, Dec 26, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    292
    Christopher Reed
    Dec 26, 2005
  2. Stephanie Wilks
    Replies:
    8
    Views:
    1,717
    Thomas Mlynarczyk
    Feb 6, 2004
  3. Dung Ping

    Web Site Statistics

    Dung Ping, Nov 11, 2005, in forum: HTML
    Replies:
    5
    Views:
    392
    Steve Pugh
    Nov 15, 2005
  4. Dung Ping

    Statistics on Web Site

    Dung Ping, Dec 7, 2005, in forum: HTML
    Replies:
    3
    Views:
    340
    Dung Ping
    Dec 9, 2005
  5. Dung Ping

    Site Statistics

    Dung Ping, Apr 28, 2006, in forum: HTML
    Replies:
    2
    Views:
    392
    Dung Ping
    Apr 28, 2006
Loading...

Share This Page