473,507 Members | 2,441 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IHttpModule won't compile

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
Jun 27 '08 #1
1 1454
If this module code is in App_Code and has no namespace, type="MyModule" in
<addis 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" <er**********@gmail.comwrote in message
news:67**********************************@d45g2000 hsc.googlegroups.com...
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

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1165
by: moid | last post by:
Sir we are implementing front controller in asp.net. we implement three event-handler 1. PreRequestHandlerExecute 2. PostRequestHandlerExecute 3. BeginRequest we just want to initialize...
2
2361
by: Kenneth Myhra | last post by:
Hi, We have been trying to develop an IHTTPModule (that was supposed to replace or take over the ISAPI Filters, as far as we know). We have developed one in C# and it seems to be working. The...
2
1638
by: Kenneth Myhra | last post by:
Hi all, We are trying to make an ISAPI Filter, in .NET by implementing the IHttpModule interface, that will authorize the request for certain binary file types (GET), this is working fine. But we...
5
2359
by: Andrew Lippitt | last post by:
What gaurantees are there in the way of which thread the events are called from. I've seen: Thread A Begin Thread B Begin Thread A End Thread A End That seems to indicate that Begin and End...
2
2377
by: silesius | last post by:
Hi all, I'm using Visual Studio to create an HttpModule. I created a class library project added my code and two directives System and System.Web, but every time I try to compile it gives me this...
4
1836
by: Mike | last post by:
I've created a custom IHttpModule that does custom authentication. Currently it stores authenticated user info in a hashtable within the class so I don't have to re-authenticate against a database...
0
900
by: Umut Tezduyar | last post by:
This post is related with .Net 1.1. I have written my custom module by inheriting IHttpModule. I realized that, at the first compile, framework creates the instance of my module and then caches...
6
1388
by: Andy G | last post by:
I am trying to implement the global error handling described on this page... http://www.dotnetdevs.com/articles/GlobalErrorHandling.aspx I'm a VB person and don't understand much of C# when it...
8
2909
by: =?Utf-8?B?UGhpbGlw?= | last post by:
When is the IHttpModule Dispose driven ?....at application recycle time ? I developed a test HttpModule to trace INIT, BeginRequest, EndRequest and Dispose....and the Dispose never gets driven. ...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5623
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.