Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > IHttpModule won't compile

Reply
Thread Tools

IHttpModule won't compile

 
 
Eric Goforth
Guest
Posts: n/a
 
      05-22-2008
Hello,

I found a C# example on the web that used an httpmodule. I've
translated it to VB.NET and the website compiles fine, but when I
build the website the iHttpModule doesn't compile, I can't figure out
why. I do have the following entry in my web.config file:

<system.web><httpModules><add name="MyModule" type="MyModule.MyModule"/
></httpModules></system.web>


My iHttpModule Class implements iHttpModule (of course). I also have
an Init method that Implements IHttpModule.Init and Dispose method
that Implements IHttpModule.Dispose.

I think that my problem may be the syntax in the httpModules section
of the web.config file. My site is structured like:

/TestAppVB

web.config

myfile1.aspx

myfile1.aspx.vb

myfile2.aspx

myfile2.aspx.vb

/MyModule

MyModule.vb

MyModule.vb looks like:

'--------------------------------------------------------------------------------------
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Text
Imports System.Threading
Imports System.IO
Imports System.Reflection
Imports System.Web
Imports System.Xml
Imports System.Xml.XPath


'Namespace MyModule
Public Class MyModule
Implements IHttpModule, IConfigurationSectionHandler

Public Sub Dispose() Implements IHttpModule.Dispose
' add clean-up code here if required
End Sub
Public Sub Init(ByVal app As HttpApplication) Implements
IHttpModule.Init
' add init code here if required
End Sub

End Class
'End Namespace
'--------------------------------------------------------------------------------------

The code example that I found originally had this module in it's own
namespace, but I commented that out to try to simplify things. I was
thinking about trying to "flatten" the file structure and put MyModule
in the same virtual folder as the .aspx and .aspx.vb files.

Thanks,

Eric
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      05-22-2008
If this module code is in App_Code and has no namespace, type="MyModule" in
<add> is enough. If you have web site project, it (the class file) cannot
reside at same level with the pages etc since it won't get compiled. With
web project the type is built into a dll, and you need to specify the
assembly name (dll's name) in type attribute

type="MyModuleNamespace.MyModule, MyModuleAssembly"

when your module has MyModuleNamespace namespace, its name is MyModule and
it resides in MyModuleAssembly.dll

If you have the module in same dll with web project, it is the web
application's single dll which you should specify into type.

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


"Eric Goforth" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello,
>
> I found a C# example on the web that used an httpmodule. I've
> translated it to VB.NET and the website compiles fine, but when I
> build the website the iHttpModule doesn't compile, I can't figure out
> why. I do have the following entry in my web.config file:
>
> <system.web><httpModules><add name="MyModule" type="MyModule.MyModule"/
>></httpModules></system.web>

>
> My iHttpModule Class implements iHttpModule (of course). I also have
> an Init method that Implements IHttpModule.Init and Dispose method
> that Implements IHttpModule.Dispose.
>
> I think that my problem may be the syntax in the httpModules section
> of the web.config file. My site is structured like:
>
> /TestAppVB
>
> web.config
>
> myfile1.aspx
>
> myfile1.aspx.vb
>
> myfile2.aspx
>
> myfile2.aspx.vb
>
> /MyModule
>
> MyModule.vb
>
> MyModule.vb looks like:
>
> '--------------------------------------------------------------------------------------
> Imports Microsoft.VisualBasic
> Imports System
> Imports System.Collections
> Imports System.Configuration
> Imports System.Text
> Imports System.Threading
> Imports System.IO
> Imports System.Reflection
> Imports System.Web
> Imports System.Xml
> Imports System.Xml.XPath
>
>
> 'Namespace MyModule
> Public Class MyModule
> Implements IHttpModule, IConfigurationSectionHandler
>
> Public Sub Dispose() Implements IHttpModule.Dispose
> ' add clean-up code here if required
> End Sub
> Public Sub Init(ByVal app As HttpApplication) Implements
> IHttpModule.Init
> ' add init code here if required
> End Sub
>
> End Class
> 'End Namespace
> '--------------------------------------------------------------------------------------
>
> The code example that I found originally had this module in it's own
> namespace, but I commented that out to try to simplify things. I was
> thinking about trying to "flatten" the file structure and put MyModule
> in the same virtual folder as the .aspx and .aspx.vb files.
>
> Thanks,
>
> Eric



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cant compile on linux system.cant compile on cant compile onlinux system. Nagaraj C++ 1 03-01-2007 11:18 AM
IHttpModule, Context.Session == null? oliver.wulff@zurich.ch ASP .Net 1 01-22-2004 07:50 PM
Front Controller / IHttpModule moid ASP .Net 0 12-25-2003 02:37 PM
http pipline, ihttpmodule and filtering responses Steven Livingstone ASP .Net 2 10-20-2003 12:25 PM
Re: IHttpModule trouble registering in web.config Duncan Godwin ASP .Net 0 06-24-2003 11:18 PM



Advertisments