Site Statistics

P

Paps

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

thanks
Paps
 
J

Jacob Yang [MSFT]

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.
 
P

Paps

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
 
J

Jacob Yang [MSFT]

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 (e-mail address removed). 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.
 
P

Paps

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
 
J

Jacob Yang [MSFT]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top