public void ProcessRequest(HttpContext context) { int id = int.Parse(context.Request["id"].ToString()); SqlDAO<BlogImage> bi = new SqlDAO<BlogImage>(ConfigurationManager.ConnectionStrings["DB"].ConnectionString); BlogImage img = bi.getSingle("WHERE _dbId = " + id); if (img != null && img.ImageData != null) { using (System.IO.MemoryStream m = new System.IO.MemoryStream()) { img.ImageData.Save(m, img.ImageData.RawFormat); context.Response.BinaryWrite(m.ToArray()); context.Response.Flush(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (id > 0) { SqlDAO<Blog> bldao = new SqlDAO<Blog>(ConfigurationManager.ConnectionStrings["DB"].ConnectionString); Blog bl = bldao.getSingle("WHERE _dbId = " + id); if (bl != null) { Loader.load(bl, bldao.emulate<DataObject>(typeof(Blog))); blog = bl; } } else { Blog t = new Blog(); t.Sections = new List<BlogSection>(); t.Tags = new List<BlogTag>(); t.Attachments = new List<BlogAtachment>(); this.blog = t; } bind(); } }