views:

48

answers:

2

I'm trying to display an image returned by an aspx page like this

<asp:Image ID="ButtonImage" runat="server" 
         Width="200" 
         Height="113" 
         BackColor="LightGray" 
         ImageUrl="/Editor/OpenMedia.aspx?path=336!TestImage.jpg"/>

OpenMedia.aspx

public partial class OpenMedia : MemberPage
{
    protected void Page_Init(object sender, EventArgs e)
    {
       string path = Request.QueryString["path"];
       HASFile file = new HASFile(path);

       HASConnection con = new HASConnection(ConfigurationManager.AppSettings["HASUrl"]);
       HASReader reader = new HASReader(con);

       reader.getFile(file, Response.OutputStream);
       Response.ContentType = "image/jpeg"; 
    }
}

When I look at the response with fiddler the image is returned correctly and it works correctly in Firefox but not in IE. How come this isn't working with IE?

A: 

Try inverting the sequence:

protected void Page_Init(object sender, EventArgs e) 
{ 
   Response.ContentType = "image/jpeg";  

   string path = Request.QueryString["path"]; 
   HASFile file = new HASFile(path); 
   HASConnection con = new HASConnection(ConfigurationManager.AppSettings["HASUrl"]); 
   HASReader reader = new HASReader(con); 

   reader.getFile(file, Response.OutputStream); 
} 
Paulo Santos
Didn't make any difference at all.
Joakim Karlsson
A: 

It turned out to be that some of the images I tested with where corrupt in some way that internet explorer couldn't solve. Firefox could display the images even if they where corrupt.

Joakim Karlsson