I created a simple HttpModule for registering the use of an existing web service. There dll containing one class
public class TrackingModule : System.Web.IHttpModule
{
public TrackingModule(){}
public void Init(System.Web.HttpApplication context)
{
context.BeginRequest+=new EventHandler(context_BeginRequest);
}
public void Dispose()
{
}
private void context_BeginRequest(object sender, EventArgs e)
{
try
{
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish( new Exception("Log attept") );
HttpApplication app = (HttpApplication)sender;
string method = app.Request.RawUrl;
SaveUseToDatabase( app.Request.UserHostAddress, method );
}
catch( Exception ex )
{
try
{
Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManager.Publish( ex );
}
catch{}
}
}
}
After compiling the dll, I add it to the webservice bin folder and add it to the webservice web.config:
<system.web>
<httpModules>
<add name="TrackingModule" type="WebserviceTrackingModule.TrackingModule, WebserviceTrackingModule"/>
This works fine on my computer, but when I copy it to a production server, nothing happens. There are no new entries in the database, no entries are recorded by ExceptionManager. As if that is not the case.
What can I lose?
Edit: After running another test, I can add that it works when I add it for a web service that has its own top-level virtual directory. It does not work for web services that are in virtual directories, which are subfolders of another virtual directory.
, HttpModules , , .