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

  • Home
  • SEARCH
  • 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 1042543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:31:31+00:00 2026-05-16T15:31:31+00:00

I have a generic handler public void ProcessRequest(HttpContext context) { context.Response.ContentType = image/jpeg,png,jpg,gif; int

  • 0

I have a generic handler

public void ProcessRequest(HttpContext context)
    {

        context.Response.ContentType = "image/jpeg,png,jpg,gif";
        int newsId = int.Parse(context.Session["newsId"].ToString());
        int FK_UnitId = int.Parse(context.Session["UserData"].ToString());
        Managers.Photo p = new Managers.Photo();
        string dirPath = ConfigurationManager.AppSettings.GetValues("ThePath").First() + "/" + "NewsImages" + "/" + "UnitNum" + FK_UnitId.ToString() + "_" + "NewsNum" + newsId.ToString() + "/";
        string dirPathForTextFiles = ConfigurationManager.AppSettings.GetValues("ThePath").First() + "/" + "NewsTextFiles" + "/" + "UnitNum" + FK_UnitId.ToString() + "_" + "NewsNum" + newsId + "/";
        DataTable dt = p.GetAllPhotos(newsId);
        List<string> l = new List<string>(dt.Rows.Count);
        byte[] b = null;
        FileStream f;
        try
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                l.Add(dirPath + dt.Rows[i]["photoName"].ToString());
                f = new FileStream(l[i].ToString(), FileMode.Open, FileAccess.ReadWrite);
                b = new byte[f.Length];
                f.Read(b, 0, b.Length);
                context.Response.OutputStream.Write(b, 0, b.Length);
                context.ClearError();
                f = null;
                b = null;

            }
        }
        catch (IOException e)
        {
           string message =  e.Message;
        }


    }

and a list view on my page: the .cs file contains

Session.Add("newsId", newsId);  
string dirPath =ConfigurationManager.AppSettings.GetValues("ThePath").First() + "/" + "NewsImages" + "/" + "UnitNum" + FK_UnitId.ToString() + "_" + "NewsNum" + newsId + "/";  
string dirPathForTextFiles =ConfigurationManager.AppSettings.GetValues("ThePath").First() + "/" + "NewsTextFiles" + "/" + "UnitNum" + FK_UnitId.ToString() + "_" + "NewsNum" + newsId + "/";  
DataTable dt = p.GetAllPhotos(int.Parse(newsId));  
List<string> l = new List<string>(dt.Rows.Count);  
for (int i = 0; i < dt.Rows.Count; i++)  
{  
    l.Add(dirPath + dt.Rows[i]["photoName"].ToString());  
}  
lv_showImages.DataSource = l;  
lv_showImages.DataBind();

my source

<asp:ListView ID="lv_showImages" GroupItemCount="4" runat="server">
    <ItemTemplate>
         <asp:Image ID="img_newsImage" Height="100px" Width="100px" runat="server ImageUrl ='<%# "RetreiveImage.ashx" %>' />
   </ItemTemplate>  
</asp:ListView>`

Now my problem:

When the list has more than one path to set of images, only the first image has appeared and repeated, although I debug my handler and I find that length of b the byte array differs in the loop and this means that it is supposed to write different images rather than repeat the first image by the number of images, I don’t know why the first image only appeared.

  • 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-16T15:31:32+00:00Added an answer on May 16, 2026 at 3:31 pm

    I don’t think you can return multiple images in a single request. I’m guessing that you are writing the contents of all of your images to the response but the browser only reads up to the end of the first image. You will have to change your handler to accept an image identifier parameter and return only that image.

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

Sidebar

Ask A Question

Stats

  • Questions 542k
  • Answers 542k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use: SELECT p.id as a, p.url as b, t.id as… May 17, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer There are two parts to the problem First Issue You… May 17, 2026 at 3:19 am
  • Editorial Team
    Editorial Team added an answer I thought I'd show the regex approach, too. It doesn't… May 17, 2026 at 3:18 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a generic class in C# with 2 constructors: public Houses(params T[] InitialiseElements)
I have a generic list... public List<ApprovalEventDto> ApprovalEvents The ApprovalEventDto has public class ApprovalEventDto
I have some generic types, like the following: public struct Tuple<T1, T2> { ...
I have an interface method public void Execute(ICommand command); which needs to pass known
I have a generic class that should allow any type, primitive or otherwise. The
I have a generic Repository<T> class I want to use with an ObjectDataSource. Repository<T>
I have a generic class that I'm trying to implement implicit type casting for.
I have a 'generic' boiler plate static method for checking for InvokeRequired and invoking
I have a generic list of objects in C#, and wish to clone the
I have a generic list of objects in C#, for example sake, here's what

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.