<%@ WebHandler Language="C#" Class="Handler" %> using System; using System.Web; using System.Data.SqlClient; public class Handler : IHttpHandler { SqlConnection myConnection; SqlCommand cmd; public Handler() { myConnection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["myDB"].ConnectionString); cmd = new SqlCommand("", myConnection); myConnection.Open(); } public void ProcessRequest (HttpContext context) { try { string sql = "Select TPImage,id,Image_Type from TProduct where Id=@Id"; cmd.CommandText = sql; cmd.Parameters.Add("@Id", System.Data.SqlDbType.Int).Value = context.Request.QueryString["Id"]; cmd.Prepare(); SqlDataReader dr = cmd.ExecuteReader(); dr.Read(); context.Response.ContentType = dr["Image_Type"].ToString(); context.Response.BinaryWrite((byte[])dr["TPImage"]); //باید برای عکس یکی از این فایل ساخته شود تا که بتونی هر عکس رو جدا لود کرد. dr.Close(); myConnection.Close(); } catch (Exception ex) { //System.Windows.Forms.MessageBox.Show(ex.Message); } } public bool IsReusable { get { return false; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)