If ContentType column was not in my table so how to mention it?
and error occured during run the snippet:
Error: "Unable to cast object of type 'System.DBNull' to type 'System.Byte[]'."
in this line: Byte[] bytes = (Byte[])dt.Rows[0]["MainImg"];
Byte[] bytes = (Byte[])dt.Rows[0]["MainImg"];
context.Response.Buffer = true;
context.Response.Charset = "";
context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
context.Response.ContentType = dt.Rows[0]["MainImg"].ToString();
context.Response.AddHeader("content-disposition", "attachment;filename=" + dt.Rows[0]["ImgName"].ToString());
context.Response.BinaryWrite(bytes);
context.Response.Flush();
context.Response.End();