开发者

IISHandler error does not implement interface member 'System.Web.IHttpHandler.IsReusable',

开发者 https://www.devze.com 2023-03-21 22:46 出处:网络
How do i fix this error Error3\'FMMadminModule.IISHandler1\' does not implement interface member \'System.Web.IHttpHandler.IsReusable\',

How do i fix this error

Error   3   'FMMadminModule.IISHandler1' does not implement interface member 'System.Web.IHttpHandler.IsReusable',
 Error  4   'FMMadminModule.IISHandler1' does not implement interface member 'System开发者_如何学JAVA.Web.IHttpHandler.ProcessRequest(System.Web.HttpContext)'   

Here is my handler

 `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;
                }
            }
        }
    }
}


You've declared a class twice. Remove the IISHandler1 class at the top, resulting in this:

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;
                }
            }
        }
}


You have nested two classes. Try removing one of the nestings:

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;
        }
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号