<%@ WebHandler Language="C#" Class="FileCS" %> using System; using System.Web; using System.Data.SqlClient; using System.Configuration; public class FileCS : IHttpHandler { public void ProcessRequest(HttpContext context) { int id = int.Parse(context.Request.QueryString["id"]); byte[] bytes; string contentType; string strConnString = ConfigurationManager.ConnectionStrings["Crime"].ConnectionString; string name; using (SqlConnection con = new SqlConnection(strConnString)) { using (SqlCommand cmd = new SqlCommand()) { cmd.CommandText = "select Names, Data, ContentType from tblFiles where Id=@Id"; cmd.Parameters.AddWithValue("@Id", id); cmd.Connection = con; con.Open(); cmd.CommandTimeout = int.MaxValue; SqlDataReader sdr = cmd.ExecuteReader(); sdr.Read(); bytes = (byte[])sdr["Data"]; contentType = sdr["ContentType"].ToString(); name = sdr["Names"].ToString(); con.Close(); } } context.Response.Clear(); context.Response.Buffer = true; context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name); context.Response.ContentType = contentType; context.Response.BinaryWrite(bytes); context.Response.End(); } public bool IsReusable { get { return false; } } } My above generic handler file code for reading video from datbase gives Error : Exception of type 'System.OutOfMemoryException' was thrown. how to solve this error. Please help.....
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)