Last post Jul 25, 2013 11:33 AM by Afzaal.Ahmad.Zeeshan
Jul 23, 2013 07:43 AM|ssvikramuk|LINK
I have stored all my website images in my DB. Each time i refresh it's taking long time to load. How can I cache the images?
Jul 23, 2013 07:47 AM|ramu.net|LINK
Save all the images at a folder in your project is the good solution.
Use the session variable to when you get images first time.
Jul 23, 2013 07:49 AM|ssvikramuk|LINK
How to use session variable for dynamic images?. Please advise me.
Jul 24, 2013 05:21 AM|Javen Yao - MSFT|LINK
Hello, here is a demo about how to save picture in session.
protected void Page_Load(object sender, EventArgs e)
if (Session["xx"] == null)
SqlConnection sqlConnection = new SqlConnection(@"Data Source=.\xx;Initial Catalog=ImageTest;Integrated Security=True");
string comText = "Select ImageData from ImageTable";
SqlCommand sqlCommand = new SqlCommand(comText, sqlConnection);
SqlDataReader dr = sqlCommand.ExecuteReader();
Session["xx"] = (byte)dr;
however, if the picture is large enouth, this method will occupy a lot of memory and it may also lead some problem in user experience. Most time save pictures in local and save the path in database is a prefer method. Thank you.
Jul 25, 2013 11:33 AM|Afzaal.Ahmad.Zeeshan|LINK
Saving the images to the Database is not a good idea. Save the name of the image in Database but save the image file to the File System.
This way, extracting image will be easy and also will be fast enough!