"Hello
from OnAuthorizeRequest in custom module.<br>"
);
}
}
}
I've created an Application under the default Web Root, and loaded my module into the App as a managed module using inetmgr. COde compiled OK, I copied it into a BIN subdirectory of my App, and I amended my web.config under the app to add the module.
However, when I make a request to my application page, I dont see eny evidence of it invoking my custom module. I've turned on server side tracing but again no sign of my module in the trace.
I don't remeber very well, because I 've been using these tags from sometime ago. As of today, the net effect is that if also write the same <add name="MyModule...> inside <httpModules> section (inside <system.web> section), I have my modules working from
IIS5 to IIS7.5 no matter if in integrated or pipeline mode.
Regards,
Francisco.
If this post helps to solve your question, please mark it as Answer.
Graham_H
Member
3 Points
2 Posts
Why is my custom Module not being invoked?
Feb 23, 2011 02:42 PM|LINK
Hi,
I'm trying to understand IIS and ASN.NET better by trying some examples I've found on the MS Site. However my first attempt has got me knowwhere :-(
This is all on my laptop running IIS 7, Vista Pro, and Viual Web Dev 2010 Express.
I've set the .NET Framework to 3.5 for my Project.
Code is...
using
System;
using
System.Collections.Generic;
using
System.Text;
using
System.Web;namespace
MyIIS7Project {public class MyModule : IHttpModule
{
public void Dispose()
{
// throw new NotImplementedException();
}
public void Init(HttpApplication
context)
{
// Set up the events we want to catch
context.AuthorizeRequest +=
new EventHandler
(OnAuthorizeRequest);
}
// Module Handlers
public void OnAuthorizeRequest (Object source, EventArgs
e)
{
HttpApplication app = (HttpApplication
)source;
HttpRequest
request = app.Context.Request;
app.Context.Response.Write(
"Hello from OnAuthorizeRequest in custom module.<br>"
);
}
}
}
I've created an Application under the default Web Root, and loaded my module into the App as a managed module using inetmgr. COde compiled OK, I copied it into a BIN subdirectory of my App, and I amended my web.config under the app to add the module.
However, when I make a request to my application page, I dont see eny evidence of it invoking my custom module. I've turned on server side tracing but again no sign of my module in the trace.
Any thoughts about where to look for the problem?
fpl
Member
76 Points
13 Posts
Re: Why is my custom Module not being invoked?
Feb 24, 2011 06:43 PM|LINK
Hello,
Have you added your module in web.config file? If that's not the case, Make sure yor web.config has the following:
<system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <remove name="MyModule" /> <add name="MyModule" type="MyIIS7Project.MyModule"/> </modules> </system.webServer>Hope this helps.
Regards,
Francisco
PS. If this post solves your problem, please mark it as Answer.
Graham_H
Member
3 Points
2 Posts
Re: Why is my custom Module not being invoked?
Feb 25, 2011 06:36 PM|LINK
Thanks,
I had most of it apart from "<validation validateIntegratedModeConfiguration="false"/> " and " <remove name="MyModule" /> "
Not sure why tyhese made such a difference but they did.
Thanks for the help.
fpl
Member
76 Points
13 Posts
Re: Why is my custom Module not being invoked?
Feb 27, 2011 01:53 AM|LINK
Hello Graham,
Thanks for the "answer".
I don't remeber very well, because I 've been using these tags from sometime ago. As of today, the net effect is that if also write the same <add name="MyModule...> inside <httpModules> section (inside <system.web> section), I have my modules working from IIS5 to IIS7.5 no matter if in integrated or pipeline mode.
Regards,
Francisco.