TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Hazel Mahmud
1.4k
315
70.7k
return default image in image handler
Mar 16 2015 11:58 PM
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();
}
}
}
TQ in advance
Reply
Answers (
4
)
how to access C# application remotly
Formatting in excel failing with C Sharp