<%@ webhandler language="C#" class="NWEmpPhotoHandler" %> using System; using System.Web; using System.Data; using System.Data.SqlClient; public class NWEmpPhotoHandler : IHttpHandler { public bool IsReusable { get { return true; } } public void ProcessRequest(HttpContext ctx) { string id = ctx.Request.QueryString["id"]; SqlConnection con = new SqlConnection("Data Source=server;Initial Catalog=schema;Persist Security Info=True;User ID=userid;Password=password"); SqlCommand cmd = new SqlCommand("SELECT filedata FROM mytable WHERE DocID = @DocID", con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add( "@DocID", id); con.Open(); byte[] doct = (byte[])cmd.ExecuteScalar(); con.Close(); ctx.Response.ContentType = "application/pdf"; // ctx.Response.OutputStream.Write(doct, 78, doct.Length - 78); ctx.Response.BinaryWrite(doct); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)