-
Notifications
You must be signed in to change notification settings - Fork 0
/
ShowThumbnail.ashx
50 lines (41 loc) · 1.24 KB
/
ShowThumbnail.ashx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<%@ WebHandler Language="C#" Class="ShowThumbnail" %>
using System;
using System.Web;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
public class ShowThumbnail : IHttpHandler {
public void ProcessRequest(HttpContext context)
{
SqlDataReader rdr = null;
SqlConnection conn = new SqlConnection();
SqlCommand cmd = new SqlCommand();
try
{
string connStr = ConfigurationManager.ConnectionStrings["fuddleConnectionString"].ConnectionString;
conn = new SqlConnection(connStr);
cmd = new SqlCommand("SELECT Image_thumbnail FROM [Image_table] WHERE Image_id = " + context.Request.QueryString["imgID"], conn);
conn.Open();
rdr = cmd.ExecuteReader();
while (rdr.Read())
{
context.Response.ContentType = "image/png";
context.Response.BinaryWrite((byte[])rdr["Image_thumbnail"]);
}
if (rdr != null)
rdr.Close();
}
finally
{
conn.Close();
conn.Dispose();
}
}
public bool IsReusable
{
get {
return true;
}
}
}