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\H ttpModules\Http Modules.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\H ttpModules\Http Modules.cs(9): The type or namespace name
'HttpApplicatio n' 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 HttpModuleExamp les
{
public class CustomHttpModul e : IHttpModule
{
//IHttpModule Members
public void Init(HttpApplic ation httpApp)
{
httpApp.BeginRe quest += new EventHandler(th is.OnBeginReque st);
httpApp.EndRequ est += new EventHandler(th is.OnEndRequest );
}
public void Displose()
{
//Usually nothing has to happen here
}
// Event Handlers
public void OnBeginRequest( object o, EventArgs ea)
{
HttpApplication httpApp = (HttpApplicatio n) o;
HttpContext ctx = HttpContext.Cur rent;
ctx.Response.Wr ite("Beginning Request <br>");
}
public void OnEndRequest(ob ject o, EventArgs ea)
{
HttpApplication httpApp = (HttpApplicatio n) o;
HttpContext ctx = HttpContext.Cur rent;
ctx.Response.Wr ite("Ending Request <br>");
}
}
}
*************** *************** *************** ************
Thanks,
Tom
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\H ttpModules\Http Modules.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\H ttpModules\Http Modules.cs(9): The type or namespace name
'HttpApplicatio n' 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 HttpModuleExamp les
{
public class CustomHttpModul e : IHttpModule
{
//IHttpModule Members
public void Init(HttpApplic ation httpApp)
{
httpApp.BeginRe quest += new EventHandler(th is.OnBeginReque st);
httpApp.EndRequ est += new EventHandler(th is.OnEndRequest );
}
public void Displose()
{
//Usually nothing has to happen here
}
// Event Handlers
public void OnBeginRequest( object o, EventArgs ea)
{
HttpApplication httpApp = (HttpApplicatio n) o;
HttpContext ctx = HttpContext.Cur rent;
ctx.Response.Wr ite("Beginning Request <br>");
}
public void OnEndRequest(ob ject o, EventArgs ea)
{
HttpApplication httpApp = (HttpApplicatio n) o;
HttpContext ctx = HttpContext.Cur rent;
ctx.Response.Wr ite("Ending Request <br>");
}
}
}
*************** *************** *************** ************
Thanks,
Tom
Comment