2013-01-11 52 views
0

讓我們考慮兩個類具有相同名稱的空間和擴展的IHttpHandler如下創建ASP.NET HTTP模塊

第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("The page request is " + context.Request.RawUrl.ToString()); 
      } 

    } 

    public bool IsReusable 
    { 
      get 
      { 
       return true; 
      } 
    } 
} 

2類:

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#可以看到類似所有的模塊。你有解決這個問題的想法嗎?

回答

1

您想創建一個模塊並實現HTTP Handler的接口。使用此IHttpModule

+0

我已經創建了模塊,但我需要在每個請求 – GowthamanSS

+0

一次啓動兩個類,但在兩個類中您正在實現IHTTPHandler。你得到的錯誤是由於沒有實現IHttpModule。 –

+0

它就像這個公共類clsMyHandler2:IHttpModule –