I am trying to build an HttpModule and am building just the skeleton part of
the program in VS 2003 and am getting a couple of errors. But this is how I
have seen the file built in a couple of different places.
The errors are:
C:\VSProjects\HttpModules\HttpModules.cs(6): The type or namespace name
'IHttpModule' could not be found (are you missing a using directive or an
assembly reference?)
and
C:\VSProjects\HttpModules\HttpModules.cs(9): The type or namespace name
'HttpApplication' could not be found (are you missing a using directive or
an assembly reference?)
I am building this as a class library and the Using clauses are the same as
I have seen elsewhere. Do I need something else (I assume I do)?
************************************************** *******
using System;
using System.Web;
namespace HttpModuleExamples
{
public class CustomHttpModule : IHttpModule
{
//IHttpModule Members
public void Init(HttpApplication httpApp)
{
httpApp.BeginRequest += new EventHandler(this.OnBeginRequest);
httpApp.EndRequest += new EventHandler(this.OnEndRequest);
}
public void Displose()
{
//Usually nothing has to happen here
}
// Event Handlers
public void OnBeginRequest(object o, EventArgs ea)
{
HttpApplication httpApp = (HttpApplication) o;
HttpContext ctx = HttpContext.Current;
ctx.Response.Write("Beginning Request <br>");
}
public void OnEndRequest(object o, EventArgs ea)
{
HttpApplication httpApp = (HttpApplication) o;
HttpContext ctx = HttpContext.Current;
ctx.Response.Write("Ending Request <br>");
}
}
}
************************************************** *******
Thanks,
Tom 2 5443
Tshad,
IHttpModule interface lives in System.Web. It's not sufficient just to put a
"using" directive at the top of your class. If the assembly is not in the
default assemblies loaded for the project type, you need to specifically add
a reference to it.
Peter
--
Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
"tshad" wrote: I am trying to build an HttpModule and am building just the skeleton part of the program in VS 2003 and am getting a couple of errors. But this is how I have seen the file built in a couple of different places.
The errors are: C:\VSProjects\HttpModules\HttpModules.cs(6): The type or namespace name 'IHttpModule' could not be found (are you missing a using directive or an assembly reference?)
and
C:\VSProjects\HttpModules\HttpModules.cs(9): The type or namespace name 'HttpApplication' could not be found (are you missing a using directive or an assembly reference?)
I am building this as a class library and the Using clauses are the same as I have seen elsewhere. Do I need something else (I assume I do)?
************************************************** ******* using System; using System.Web;
namespace HttpModuleExamples { public class CustomHttpModule : IHttpModule { //IHttpModule Members public void Init(HttpApplication httpApp) { httpApp.BeginRequest += new EventHandler(this.OnBeginRequest); httpApp.EndRequest += new EventHandler(this.OnEndRequest); } public void Displose() { //Usually nothing has to happen here }
// Event Handlers public void OnBeginRequest(object o, EventArgs ea) { HttpApplication httpApp = (HttpApplication) o; HttpContext ctx = HttpContext.Current; ctx.Response.Write("Beginning Request <br>"); }
public void OnEndRequest(object o, EventArgs ea) { HttpApplication httpApp = (HttpApplication) o; HttpContext ctx = HttpContext.Current; ctx.Response.Write("Ending Request <br>"); } } } ************************************************** *******
Thanks,
Tom
"Peter Bromberg [C# MVP]" <pb*******@yahoo.nospammin.com> wrote in message
news:82**********************************@microsof t.com... Tshad, IHttpModule interface lives in System.Web. It's not sufficient just to put a "using" directive at the top of your class. If the assembly is not in the default assemblies loaded for the project type, you need to specifically add a reference to it.
That did it.
I assumed that since it worked fine for my Web Applications, it would work
for my Classes. But the Web Applications assume that it will need that
library and a class doesn't necessarily know that, I would guess.
Thanks,
Tom Peter -- Co-founder, Eggheadcafe.com developer portal: http://www.eggheadcafe.com UnBlog: http://petesbloggerama.blogspot.com
"tshad" wrote:
I am trying to build an HttpModule and am building just the skeleton part of the program in VS 2003 and am getting a couple of errors. But this is how I have seen the file built in a couple of different places.
The errors are: C:\VSProjects\HttpModules\HttpModules.cs(6): The type or namespace name 'IHttpModule' could not be found (are you missing a using directive or an assembly reference?)
and
C:\VSProjects\HttpModules\HttpModules.cs(9): The type or namespace name 'HttpApplication' could not be found (are you missing a using directive or an assembly reference?)
I am building this as a class library and the Using clauses are the same as I have seen elsewhere. Do I need something else (I assume I do)?
************************************************** ******* using System; using System.Web;
namespace HttpModuleExamples { public class CustomHttpModule : IHttpModule { //IHttpModule Members public void Init(HttpApplication httpApp) { httpApp.BeginRequest += new EventHandler(this.OnBeginRequest); httpApp.EndRequest += new EventHandler(this.OnEndRequest); } public void Displose() { //Usually nothing has to happen here }
// Event Handlers public void OnBeginRequest(object o, EventArgs ea) { HttpApplication httpApp = (HttpApplication) o; HttpContext ctx = HttpContext.Current; ctx.Response.Write("Beginning Request <br>"); }
public void OnEndRequest(object o, EventArgs ea) { HttpApplication httpApp = (HttpApplication) o; HttpContext ctx = HttpContext.Current; ctx.Response.Write("Ending Request <br>"); } } } ************************************************** *******
Thanks,
Tom This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Bruce B |
last post by:
Hi group,
I'm experiencing some extreme weirdness over the last week with IIS related
to it's Mappings and how .NET is behaving. I can't explain the behavior as
it seems very random.
Our...
|
by: Rob Mayo |
last post by:
What I'm trying to do is Create an ASP.Net app that has both
Windows-authenticated users and Anonymous users. The idea is this:
When authenticated users attempt to access the site, their...
|
by: nail |
last post by:
Folks,
I develop a HttpModule and it works correct, but one problem is occurs.
After I register the httpmodule in the web.config, my pages (not testing
http://localhost/site but...
|
by: Danny W |
last post by:
Hi There!
Is it possible to use HttpModule to replace the built-in ASP.NET Session
object? I want to write a HttpModule that will handle storing and retrieving
of session values from an external...
|
by: Simon-Pierre Jarry |
last post by:
Hi,
I created a custom HttpModule for managing the security of my
application. in "Init" sub, I regsiter the events doing that :
Public Sub Init(ByVal context As System.Web.HttpApplication)...
|
by: walter |
last post by:
Hi there, I know there is pool of HttpApplications, and for each request
coming in, HttpRuntime will dedicate one from pool to serve the request. My
questions are :
1. since HttpModule is plug...
|
by: Faraz |
last post by:
Hi everyone,
I am running into a slight problem. My understanding is that a custom
HttpModule will run for every request made to the server, regardless of the
extension. I do not experience this...
|
by: mattdev1000 |
last post by:
Hello,
I have an HttpModule that uses a lazy fetch to a secondary tier for
calculating some values (the calculation is can be multisecond in the
worse case). The HttpModule spins up a thread to...
|
by: Joseph Geretz |
last post by:
I'm implementing a web application whose purpose in life is to act as a data
conduit. Data is posted to my Web app in XML format, my application examines
the data and forwards it onward by posting...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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...
| |