what code to add and where do i add code that retrieve default image in image handler code that i've attached below :
public class ImageHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
Int32 ID;
if (context.Request.QueryString["nopkj_cari"] != null)
ID = Convert.ToInt32(context.Request.QueryString["nopkj_cari"]);
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpg";
Stream strm = DisplayImage(ID);
byte[] buffer = new byte[2048];
int byteSeq = strm.Read(buffer, 0, 2048);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 2048);
}
}
public Stream DisplayImage(int ID)
{
using (AseConnection persisConn = ClassConn.GetPersisConnection())
{
persisConn.Open();
AseCommand selcmd = new AseCommand("select gambar=f630gambar from t630picture where f630nopkj=" + ID, persisConn);
persisConn.Open();
object theImg = selcmd.ExecuteScalar();
try
{
return new MemoryStream((byte[])theImg);
}
catch
{
return null;
}
finally
{
persisConn.Close();
}
}
}
{
public void ProcessRequest(HttpContext context)
{
Int32 ID;
if (context.Request.QueryString["nopkj_cari"] != null)
ID = Convert.ToInt32(context.Request.QueryString["nopkj_cari"]);
else
throw new ArgumentException("No parameter specified");
context.Response.ContentType = "image/jpg";
Stream strm = DisplayImage(ID);
byte[] buffer = new byte[2048];
int byteSeq = strm.Read(buffer, 0, 2048);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 2048);
}
}
public Stream DisplayImage(int ID)
{
using (AseConnection persisConn = ClassConn.GetPersisConnection())
{
persisConn.Open();
AseCommand selcmd = new AseCommand("select gambar=f630gambar from t630picture where f630nopkj=" + ID, persisConn);
persisConn.Open();
object theImg = selcmd.ExecuteScalar();
try
{
return new MemoryStream((byte[])theImg);
}
catch
{
return null;
}
finally
{
persisConn.Close();
}
}
}
TQ in advance

Rahul BansalRank #143 · 15.9K reputationPosted Mar 16, 2015, 8:56 PM EDT
try after object theImg = selcmd.ExecuteScalar();
if (theImg==null)
{
string filename = "../Images/no_photo.jpg";
byte[] imageByte = System.IO.File.ReadAllBytes(context.Server.MapPath(filename));
return new MemoryStream((byte[])imageByte);
}
else{return new MemoryStream((byte[])theImg);}
Hazel MahmudRank #4,713 · 329 reputationPosted Mar 16, 2015, 11:44 PM EDT
Rahul BansalRank #143 · 15.9K reputationPosted Mar 17, 2015, 12:37 AM EDT
HttpContext.Current.Server.MapPath
Hazel MahmudRank #4,713 · 329 reputationPosted Mar 21, 2015, 8:03 PM EDT