Click here to Skip to main content
14,302,838 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi everyone,

Let me explain the scenario.

I have to display a page which will show user's personal information along with his profile picture and signature (after log-in).
The profile picture and signature are stored in database.
I am using 2 Image control on the web page. I am retrieving the image using http handler.
<asp:Image ID="imgUserImage" runat="server" AlternateText="User Photo" Height="130px" Width="150px" />
<br /> <asp:Image ID="imgUserSign" runat="server" AlternateText="User Signature"

Height="40px" Width="150px" />


Now the user id will be obtained at runtime. So I am assigning the url to the image at runtime like this:
//show user image
imgUserImage.ImageUrl = "showUserImage.ashx?imgtype=photo&id=" + empid;
//show user signature
imgUserImage.ImageUrl = "showUserImage.ashx?imgtype=sig&id=" + empid;


Based on the imgtype querystring, the handler is processing the request and will display corresponding image.

Now the problem is, the ProcessRequest method is called only once (after Page_Load of aspx) which I think is correct.
Is there a way I can show both the images on the page using the handler.
I couldn't find a solution on the web. :(

Thanks!
Posted

1 solution

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

Solution 1

When a client browser sees an image tag, it sends a separate request to get the image according to the "src" attribute of the tag.
Your handler will process this request.

Accordingly there should be 3 hits against the server:
1. for your aspx page
2. for the first image (your handler will handle it)
3. for the second image (your handler will handle it)

Is that what you want to avoid?
   
v2
Comments
6,921,364 and growing 8-Nov-10 23:53pm
   
I found the issue. I was using the same Image control id for both the images. Arrrgggh!! X-(
BTW can you tell me how can we solve the issue that you are talking about - avoiding 3 requests for a page.
And thanks for your time and help. :)

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




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