Click here to Skip to main content
11,417,750 members (47,555 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET
Hello. for showing photo in my site. i am using Handler(.NET 3.5) to read from DB a and show it in DataList. But when i uploaded the site photos are shown slow.
Please look at the site:[^]

and the code that i am using:
<%@ 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);
    public void ProcessRequest (HttpContext context) {
            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"];
            SqlDataReader dr = cmd.ExecuteReader();
            context.Response.ContentType = dr["Image_Type"].ToString();
            //باید برای عکس یکی از این فایل ساخته شود تا که بتونی هر عکس رو جدا لود کرد.
        catch (Exception ex)
    public bool IsReusable {
        get {
            return false;
Thank you.
Posted 20-Jan-13 8:54am
Edited 20-Jan-13 8:58am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

1. Consider generating thumbnails for previews. On a link above to display preview about 100x100 pixels size you are spooling 1M+ pictures.

2. Imagine your website channel load if it becomes popular

3.Strictly saying, it is not recommended to store pictures of a such big size in the database.

4. consider supporting http caching as well.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sascha Lefévre 340
1 Abhinav S 339
2 OriginalGriff 315
3 Sergey Alexandrovich Kryukov 255
4 deepankarbhatnagar 121
0 Sergey Alexandrovich Kryukov 9,345
1 OriginalGriff 7,712
2 Maciej Los 3,758
3 Abhinav S 3,601
4 Sascha Lefévre 3,198

Advertise | Privacy | Mobile
Web04 | 2.8.150427.4 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100