2011-07-21 345 views
1

如何解決這個錯誤IISHandler誤差不實現接口成員 'System.Web.IHttpHandler.IsReusable',

Error 3 'FMMadminModule.IISHandler1' does not implement interface member 'System.Web.IHttpHandler.IsReusable', 
Error 4 'FMMadminModule.IISHandler1' does not implement interface member 'System.Web.IHttpHandler.ProcessRequest(System.Web.HttpContext)' 

這裏是我的處理程序

`using System; 
using System.Web; 
using System.Data; 
using System.Data.SqlClient; 
using System.Web.SessionState; 

namespace FMMadminModule 
{ 
    public class IISHandler1 : IHttpHandler 
    { 
     /// <summary> 
     /// You will need to configure this handler in the web.config file of your 
     /// web and register it with IIS before being able to use it. For more information 
     /// see the following link: http://go.microsoft.com/?linkid=8101007 


      DataTable dt; 
      int key; 
      byte[] imageOut; 
      public void ProcessRequest(HttpContext context) 
      { 
       HttpResponse response = context.Response; 
       HttpRequest request = context.Request; 
       context.Response.ContentType = "image/jpeg"; 
       response.BufferOutput = false; 
       // get the key, the index into the DataTable 
       key = Convert.ToInt32(request.QueryString["Ind"]); 
       // Prepare the datatable to hold the SNo key and the jpeg image, which will be written out 
       dt = new DataTable(); 
       dt = (DataTable)context.Session["dt"]; 
       if (!dt.Rows[key]["Evidence"].Equals(null)) 
       { 
        imageOut = (byte[])dt.Rows[key]["Evidence"]; 
        response.OutputStream.Write(imageOut, 0, imageOut.Length); 
       } 
      } 

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

回答

1

你已經申報了上課兩次。在頂部取下IISHandler1類,造成這樣的:

using System; 
using System.Web; 
using System.Data; 
using System.Data.SqlClient; 
using System.Web.SessionState; 

namespace FMMadminModule 
{ 
     /// <summary> 
     /// You will need to configure this handler in the web.config file of your 
     /// web and register it with IIS before being able to use it. For more information 
     /// see the following link: http://go.microsoft.com/?linkid=8101007 
     public class imageHandler : IHttpHandler, IReadOnlySessionState 
     { 

      DataTable dt; 
      int key; 
      byte[] imageOut; 
      public void ProcessRequest(HttpContext context) 
      { 
       HttpResponse response = context.Response; 
       HttpRequest request = context.Request; 
       context.Response.ContentType = "image/jpeg"; 
       response.BufferOutput = false; 
       // get the key, the index into the DataTable 
       key = Convert.ToInt32(request.QueryString["Ind"]); 
       // Prepare the datatable to hold the SNo key and the jpeg image, which will be written out 
       dt = new DataTable(); 
       dt = (DataTable)context.Session["dt"]; 
       if (!dt.Rows[key]["Evidence"].Equals(null)) 
       { 
        imageOut = (byte[])dt.Rows[key]["Evidence"]; 
        response.OutputStream.Write(imageOut, 0, imageOut.Length); 
       } 
      } 

      public bool IsReusable 
      { 
       get 
       { 
        return false; 
       } 
      } 
     } 
} 
+0

好的,謝謝你。任何想法reg這個數據綁定方法,如Eval(),XPath()和Bind()只能用於數據綁定控件的上下文中。 – Sun

+0

@孫,最好再問一個問題。 – Marko

0

你嵌套了兩班。嘗試刪除其中一個嵌套:

public class imageHandler : IHttpHandler, IReadOnlySessionState 
{ 
    public void ProcessRequest(HttpContext context) 
    { 
     HttpResponse response = context.Response; 
     HttpRequest request = context.Request; 
     context.Response.ContentType = "image/jpeg"; 
     response.BufferOutput = false; 
     // get the key, the index into the DataTable 
     int key = Convert.ToInt32(request.QueryString["Ind"]); 
     // Prepare the datatable to hold the SNo key and the jpeg image, which will be written out 
     DataTable dt = new DataTable(); 
     dt = (DataTable)context.Session["dt"]; 
     if (!dt.Rows[key]["Evidence"].Equals(null)) 
     { 
      byte[] imageOut = (byte[])dt.Rows[key]["Evidence"]; 
      response.OutputStream.Write(imageOut, 0, imageOut.Length); 
     } 
    } 

    public bool IsReusable 
    { 
     get 
     { 
      return false; 
     } 
    } 
} 
相關問題