Line 66: </pages> Line 67: <httpHandlers> Line 68: <add verb="*" path="*.gif" type="Handler" /> Line 69: <remove verb="*" path="*.asmx"/> Line 70: <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
handler code is
<%@ WebHandler Language="C#" Class="Handler" %>
using System; using System.Web; using System.Data.SqlClient; using System.Web.Configuration; using System.Data; //Add this namespace using System.IO;
public class Handler : IHttpHandler { public void ProcessRequest (HttpContext context) { string constring = WebConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString; SqlConnection con = new SqlConnection(constring); con.Open(); string sql = "Select image_content, type from image where image_id=@ImageId"; SqlCommand cmd = new SqlCommand(sql, myConnection); cmd.Parameters.Add("@ImageId", SqlDbType.Int).Value = context.Request.QueryString["id"]; cmd.Prepare(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); context.Response.ContentType = dr["type"].ToString(); context.Response.BinaryWrite((byte[])dr["image_content"]); dr.Close(); myConnection.Close(); } public bool IsReusable { get { return false; } }
}
how to handler this error
|