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 536k
  • Answers 536k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Dijkstras This is how Dijkstra's works: Its not a simple… May 17, 2026 at 1:18 am
  • Editorial Team
    Editorial Team added an answer The Method Signature for hide() looks like this hide( effect,… May 17, 2026 at 1:18 am
  • Editorial Team
    Editorial Team added an answer Returning the last n articles will be fine. Because you… May 17, 2026 at 1: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 declared a generic event handler public delegate void EventHandler(); to which I
I have a Generic HTTP Handler (*.ashx) in my ASP.Net application which performs some
Why does the default generic handler code in an ASP.NET 3.5 web application add
In an ASP.NET 3.5 application, I have created an ashx handler as below: using
I have a generic method that has some parameter of a generic Type. What
I have this MemoryStream export = new MemoryStream(); iCalendarSerializer serializer = new iCalendarSerializer(iCal); serializer.Serialize(export,System.Text.Encoding.UTF8);
I have a design question :) I want to have multiple servlets but I
Suppose I have a simple EventArgs subclass: class MyArgs : EventArgs { } Consider
Can anybody tell me why is this not working. I have created a WCF
I have a bunch of IEnumerable Collections which exact number and types is subject

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.