C# 创建ASP.NET HTTP模块 让我们考虑具有相同名称空间的两类,并将IHttpHandler扩展到以下
第1类:C# 创建ASP.NET HTTP模块 让我们考虑具有相同名称空间的两类,并将IHttpHandler扩展到以下,c#,.net,web-config,ihttpmodule,C#,.net,Web Config,Ihttpmodule,第1类: using System; using System.Web; using System.IO; namespace MyPipeLine { public class clsMyHandler1 : IHttpHandler { public void ProcessRequest(System.Web.HttpContext context) { context.Response.Write
using System;
using System.Web;
using System.IO;
namespace MyPipeLine
{
public class clsMyHandler1 : IHttpHandler
{
public void ProcessRequest(System.Web.HttpContext context)
{
context.Response.Write("The page request is " + context.Request.RawUrl.ToString());
}
}
public bool IsReusable
{
get
{
return true;
}
}
}
using System;
using System.Web;
using System.IO;
namespace MyPipeLine
{
public class clsMyHandler2 : IHttpHandler
{
public void ProcessRequest(System.Web.HttpContext context)
{
context.Response.Write("The page request is " + context.Request.RawUrl.ToString());
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
第二类:
using System;
using System.Web;
using System.IO;
namespace MyPipeLine
{
public class clsMyHandler1 : IHttpHandler
{
public void ProcessRequest(System.Web.HttpContext context)
{
context.Response.Write("The page request is " + context.Request.RawUrl.ToString());
}
}
public bool IsReusable
{
get
{
return true;
}
}
}
using System;
using System.Web;
using System.IO;
namespace MyPipeLine
{
public class clsMyHandler2 : IHttpHandler
{
public void ProcessRequest(System.Web.HttpContext context)
{
context.Response.Write("The page request is " + context.Request.RawUrl.ToString());
}
public bool IsReusable
{
get
{
return true;
}
}
}
}
在上面中,命名空间是:MyPipeLine,它有两个类clsMyHandler1和clsMyHandler2
我在web.config文件中给出了如下条目
<system.webServer>
<modules>
<add name="mymodule" type="MyPipeLine.clsMyHandler1,MyPipeLine.clsMyHandler2" />
</modules>
</system.webServer>
当我编译应用程序时,它会抛出错误
无法加载文件或程序集“MyPipeLine.clsMyHandler2”或其依赖项之一。系统找不到指定的文件
我认为C#可以看到像类这样的所有模块。您对解决这个问题有什么想法吗?您想为HTTP处理程序创建一个模块和实现接口。使用此我已经创建了模块,但每次请求时我都需要启动两个类,但在这两个类中,您都在实现IHTTPHandler。您遇到的错误是由于未实现IHttpModule造成的。它类似于公共类clsMyHandler2:IHttpModule。同时,对于两个请求,您需要创建两个单独的模块并在web.config中添加单独的条目