Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
Fetch image from database using handler
shilpi gupta
Nov 24 2010 5:47 AM
12.2k
Reply
hi
i m stroing & retriving image from database.
i retrive image using handler than show image using gridview. but i face error
Configuration Error
Description:
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message:
Could not load type 'Handler'.
Source Error:
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
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Display Error Attempted to read or write protected memory. This is often an indication that other memory has been corrupted
Could not load type 'Handler'.