ASHX Image Handler randomly showing/hiding images

PSP-SPAIN

New Member
I built the ASHX Image Handler which extracts the Images stored in the SQL Server. It works beautifully, if I show the image separately. But If I try to show them in the Grid and show many pictures simultaneously, some of the pictures are not showing randomly.When I tried to refresh the page, some of the images disappear while some appears again. It is completely rendering the images randomly. Please see the image below for 4 screenshots.
Z7C3l.png
The following are my codes for the Handler. I tried to change the IsReusable True & False, but no luck. Could you please advise me how I could solve this problem? Thanks.\[code\]public class Photo : IHttpHandler{ #region IHttpHandler Members public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext context) { HttpRequest request = context.Request; if (!string.IsNullOrEmpty(request.QueryString["id"]) && !string.IsNullOrEmpty(request.QueryString["type"])) { //this hash table contain the SP parameter DAMSSQL db = DAMSSQL.GetInstance("DBName"); SqlCommand cmd = new SqlCommand("dbo.GetImage"); cmd.Parameters.Add("@ID", SqlDbType.Int).Value = http://stackoverflow.com/questions/12730535/int.Parse(request.QueryString["id"]); cmd.Parameters.Add("@Type", SqlDbType.Int).Value = http://stackoverflow.com/questions/12730535/int.Parse(request.QueryString["type"]); object obj = db.ExecuteScalar(cmd); if (obj != null) { byte[] imageArray = (byte[])obj; //checking byte[] if (imageArray != null && imageArray.Length > 0) { context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite(imageArray); } } else { context.Response.StatusCode = 404; context.Response.StatusDescription = "The requested image is not found in the system."; context.Response.End(); } } else { context.Response.StatusCode = 500; context.Response.StatusDescription = "The incoming parameters are not correct."; context.Response.End(); } } #endregion}\[/code\]
 
Back
Top