Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3217970
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:28:24+00:00 2026-05-17T15:28:24+00:00

I have the following C# code (not mine) which pulls an image out of

  • 0

I have the following C# code (not mine) which pulls an image out of a database and displays it on a web page:

public partial class Image : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        getFullImage();
    }



    public void getFullImage()
    {
        SqlConnection objCon = new SqlConnection();
        objCon = new SqlConnection(Globals.ConnectionString);
        objCon.Open();

        String TmpStr;
        try
        {

            byte[] imgData = null;

            SqlCommand objCmd = new SqlCommand("Select * from Login where user_Name='" + Request["Id"].ToString() + "'", objCon);
            SqlDataReader reader = objCmd.ExecuteReader();


            while (reader.Read())
            {
                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.AddHeader("Content-Disposition",
                    "attachment; filename=" + reader["ImageName"]);
                imgData = (byte[])reader["ImageFile"];
                TmpStr = reader["ImageFile"].ToString();
                TmpStr = TmpStr.Substring(1, TmpStr.Length - 1);
            }
            HttpContext.Current.Response.ContentType = "image/jpeg";
            HttpContext.Current.Response.BinaryWrite(imgData);
        }
        catch(Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
        finally
        {

        }
    }
}

I know it’s probably really bad practice to store images in a database and use them in this way, but I’m not a hardcore .NET dev and can’t rewrite this whole thing (much as I’d love to be able to!).

Anyhow, currently the method above creates full size (often huge) images, which are then resized using CSS, which causes them to degrade terribly in quality. I wondered if there was anything I could do to resize the image prior to render, so improve quality and reduce load time?

Thanks for any pointers folks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:28:24+00:00Added an answer on May 17, 2026 at 3:28 pm

    Here are some good links/suggestions to high quality resizing of the images:

    High Quality Image Scaling Library

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code (I know that this code is not optimized but
I have the following code that if not connected to the internet hits the
I have the following code to display JSON results from an AJAX request as
I have the following code that runs figlet that has input as a range.
I have the following code that responds to a button click, changes the view
In .Net 3.5, I have the following code. If File.Exists(sFilePath & IndexFileName & .NX)
I'm not the first to have these issues, and will list some reference posts
I have recently starting porting a small app of mine to Facebook as a
I have the following in my Activity that I use to download a users
A colleague of mine is using a horrible source code editor that leaves strange

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.