-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowImage2.ashx
More file actions
73 lines (63 loc) · 1.79 KB
/
ShowImage2.ashx
File metadata and controls
73 lines (63 loc) · 1.79 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<%@ WebHandler Language="C#" Class="ShowImage" %>
using System;
using System.Configuration;
using System.Web;
using System.IO;
using System.Data;
using System.Data.SqlClient;
public class ShowImage : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
string empno;
if (context.Request.QueryString["id"] != null)
{
empno = context.Request.QueryString["id"];
}
else
{
throw new ArgumentException("No parameter specified");
}
// context.Response.ContentType = "image/jpeg";
Stream strm = ShowEmpImage(empno);
if (strm != null)
{
byte[] buffer = new byte[4096];
int byteSeq = strm.Read(buffer, 0, 4096);
while (byteSeq > 0)
{
context.Response.OutputStream.Write(buffer, 0, byteSeq);
byteSeq = strm.Read(buffer, 0, 4096);
}
}
//context.Response.BinaryWrite(buffer);
}
public Stream ShowEmpImage(string empno)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["HPSCDBNEW"].ConnectionString);
con.Open();
SqlCommand cmd = new SqlCommand("select sigatureimage from ApplicantDetails where RegestrationNumber= @ID", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@ID", empno);
object img = cmd.ExecuteScalar();
try
{
return new MemoryStream((byte[])img);
}
catch
{
return null;
}
finally
{
con.Close();
}
}
public bool IsReusable
{
get
{
return false;
}
}
}