I am creating a very simple httpModule, this is my first, and i was wondering if you experts can give insite as to why i cannot register my httpModule. Sample code: Project Name: httpModuleTest Imports System Imports System.Web Namespace test Public Class sdsHttpModule
Implements IHttpModule 'In the Init method register for HttpApplication events by adding your handlers Public Sub Init(ByVal application As System.Web.HttpApplication) Implements IHttpModule.Init AddHandler application.BeginRequest, AddressOf Me.Application_BeginRequest
AddHandler application.EndRequest, AddressOf Me.Application_EndRequest End Sub Private Sub Application_BeginRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim app As HttpApplication = CType(sender, HttpApplication) Dim context As HttpContext
= app.Context End Sub Private Sub Application_EndRequest(ByVal sender As Object, ByVal e As System.EventArgs) Dim app As HttpApplication = CType(sender, HttpApplication) Dim context As HttpContext = app.Context End Sub Public Sub Dispose() Implements IHttpModule.Dispose
End Sub End Class End Namespace Web.Config Now, when i try to run my project i get the following error: Parser Error Message: Could not load type test.sdsHttpModule from assembly httpModuleTest. Source Error: Line 5: Line 6: Line 7: Line 8: Line 9: Can anyone
enlighten me on steps to fix this problem? Do i have to register this dll with the gac before it can be run? If so, what is the command to register a dll with the gac? thanks all in advance, i've had a ton of great help from you guys!
I have an update, i registered the httpModuleTest dll with the gac, now it gives me a new error! or fun!! Error: Parser Error Message: Could not load type sdsHttpModule from assembly httpModuleTest. Source Error: Line 5: Line 6: Line 7: Line 8: Line 9: I hope
all this reporting is helping all of you understand that!
Don't put it in GAC. Once you start dealing with GAC you'll need to strongly sign your assembly which makes versioning and maintenance confusing, etc. The issue is much simpler. When you create a project in VB it pre-pends its name to the namespace. Instead
of compiling your module into test.sdsHttpModule it compiles it into
httpModuleTest.test.sdsHttpModule. You can either change your web.config to reflect it: or go to project properties, select
General and clear what's in the 'Root namespace:' field.
Big thanks, to you. This was still valid answer :-)
I was following this: http://msdn.microsoft.com/en-us/library/ms227673(VS.80).aspx
to made simple "HelloWorldModule" test. The first phase then the module were attached to the project were working fine. But when I tried to build separate class and own dll I got the same error.
Two years later and it is not working for me in VS 2010. I wish the code sample of the web config had not been blanked. I tried changing the web.config to preface the class and assembly in the "type =" with the name of the web app namespace. This made
no difference.
jengalan
Member
80 Points
16 Posts
Problems Registering an Http Module
Sep 09, 2004 09:12 PM|LINK
jengalan
Member
80 Points
16 Posts
Re: Problems Registering an Http Module
Sep 09, 2004 09:32 PM|LINK
MilanNegovan
Participant
1421 Points
296 Posts
MVP
Re: Problems Registering an Http Module
Sep 10, 2004 04:12 PM|LINK
http://www.AspNetResources.com
ASP.NET With Emphasis On Web Standards
Petri
Member
17 Points
31 Posts
Re: Problems Registering an Http Module
May 27, 2009 12:26 PM|LINK
Big thanks, to you. This was still valid answer :-)
I was following this: http://msdn.microsoft.com/en-us/library/ms227673(VS.80).aspx
to made simple "HelloWorldModule" test. The first phase then the module were attached to the project were working fine. But when I tried to build separate class and own dll I got the same error.
--
Petri
RAlex
Member
2 Points
1 Post
Re: Problems Registering an Http Module
Jun 03, 2010 03:32 PM|LINK
Works like a charm
Wish I found this post 5 hrs ago. You deserve 5 stars.
neoloco
Member
7 Points
2 Posts
Re: Problems Registering an Http Module
Jun 19, 2010 08:39 PM|LINK
Almost 6 years ago and still valid in 2010! I just wanted to say thanks.
All the other posts I read before reading yours required registering the DLL. I was also thinking that it had to be simpler than that.
Thanks again.
joeller
Member
171 Points
161 Posts
Re: Problems Registering an Http Module
Aug 27, 2012 07:03 PM|LINK
Two years later and it is not working for me in VS 2010. I wish the code sample of the web config had not been blanked. I tried changing the web.config to preface the class and assembly in the "type =" with the name of the web app namespace. This made no difference.
velin.achev
Member
4 Points
2 Posts
Re: Problems Registering an Http Module
Nov 13, 2012 01:10 PM|LINK
Which section of web.config did you place your module registration in? System.web/httpmodules or system.webServer/modules?