473,806 Members | 2,330 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><ht tpModules><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.Ini t and Dispose method
that Implements IHttpModule.Dis pose.

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.Visua lBasic
Imports System
Imports System.Collecti ons
Imports System.Configur ation
Imports System.Text
Imports System.Threadin g
Imports System.IO
Imports System.Reflecti on
Imports System.Web
Imports System.Xml
Imports System.Xml.XPat h
'Namespace MyModule
Public Class MyModule
Implements IHttpModule, IConfigurationS ectionHandler

Public Sub Dispose() Implements IHttpModule.Dis pose
' add clean-up code here if required
End Sub
Public Sub Init(ByVal app As HttpApplication ) Implements
IHttpModule.Ini t
' 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 1467
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="MyModuleN amespace.MyModu le, MyModuleAssembl y"

when your module has MyModuleNamespa ce namespace, its name is MyModule and
it resides in MyModuleAssembl y.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**********@g mail.comwrote in message
news:67******** *************** ***********@d45 g2000hsc.google groups.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><ht tpModules><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.Ini t and Dispose method
that Implements IHttpModule.Dis pose.

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.Visua lBasic
Imports System
Imports System.Collecti ons
Imports System.Configur ation
Imports System.Text
Imports System.Threadin g
Imports System.IO
Imports System.Reflecti on
Imports System.Web
Imports System.Xml
Imports System.Xml.XPat h
'Namespace MyModule
Public Class MyModule
Implements IHttpModule, IConfigurationS ectionHandler

Public Sub Dispose() Implements IHttpModule.Dis pose
' add clean-up code here if required
End Sub
Public Sub Init(ByVal app As HttpApplication ) Implements
IHttpModule.Ini t
' 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
1174
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 the page, but dont want to load it. After BeginReq the page should Load. becuse we need to fill Datagrid through Command
2
2378
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 problem is that it is not working as it is supposed to work and we *need* to debug it. We made a search on MSDN already. Either my search keywords were irrelevant (we used <IHTTPModule debug> and <IHTTPModule debugging>, without the greater and...
2
1655
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 also want it to authorize the upload of binary files (PUT), The problem with the PUT-scenario is that the file is *not* uploaded when its extension *is* mapped up in IIS, by mapped up I mean the Application Mappings displayed when clicking on the...
5
2366
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 can't be assumed to be called from the same thread, but can I assume that the Begin will happen on the same thread that executes the request?
2
2392
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 error message "The type or namespace name 'IHttpModule' could not be found (are you missing a using directive or an assembly reference?)". What am I missing? TIA for your help Sample code: using System;
4
1851
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 everytime a logged in user hits a page. So far, it works great. Here is my question, is my approach for storing logged in users correct? Meaning, can I be sure that only one instance of my IHttpModule will be created for my Application. So...
0
914
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 it. For the next requests, framework uses the cached instance instead of creating it again. Is there a way to disable it.
6
1400
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 gets more complicated. Can someone please help me with the following statement that is in C#, I need this in VB and have been using Patel's converter but just can't get rid of the errors in VS.NET. void IHttpModule(HttpApplication application) {...
8
2928
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. After a while the INIT is redriven however the Dispose was never driven. I am trying to locate the best means to hook ASP.NET application recycling ...... Is IHttpModule Dispose a solution for this and if so how ?...... or should I use...
0
9719
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10618
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10366
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10110
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9187
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6877
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5546
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4329
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3850
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.