Hi all.
So here is my problem. The application is hosted in Windows Server 2008 with IIS7.
I have a button (from Silverlight page) that calls a new webpage (asp.net page, ext .aspx) that contains
Response.OutputStream.Write(blahblahblah) which then should prompt a download box to allow user to save an image.
Now the page basically creates a stream and then is supposed to output the stream to the user using
Response.Outputstream.Write.
Then the user is supposed to be prompted to open or save the document. This works fine in Firefox but it does not
work with IE7 or 8
Also this exact same code works with IIS6 on a Windows 2003 server.
So the only differences is the IIS6 and Windows 2003 Server to IIS7 and Windows 2008 Server.
And what happens is when I clicked the button, the page did pop up but disappear 1-2 seconds later without
prompting the download box to the user.
Here is the code that launches for Reference
//e.g file = 123424_43535.jpeg
FileInfo myFile = new FileInfo(Server.MapPath("mapImage/") + file;
using(var fs = myFile.Open(FileMode.Open, FileAccess.Read))
{
byte[] buffer;
int read;
buffer = new byte[(int)fs.Length];
Response.AddHeader("Content-Disposition", "attachment;filename=" + file);
Response.ContentType = "application/x-force-download";
Response.AddHeader("Connection", "Keep-Alive");
Response.AddHeader("Content-Length", fs.Length.ToString());
while((read = fs.Read(buffer, 0, buffer.Length)) > 0)
{
this.Response.OutputStream.Write(buffer, 0, read);
}
}
Response.End();
I have tried to replace Response.AddHeader with Response.AppendHeader, however the result is still the same.
Also, I have tried to replace the Response.ContentType with application/octet-stream and image/jpeg, I also faced
the same result.
Is there any setting/modification on server/code that I need to look on?
This problem has bugged me for a long period and a quick reply/solution will be very much appreciated.
Thanks and have a nice day.
Regards,
Kent
Loading
wai kit kanPosted Jul 15, 2009, 2:25 AM
First of all, thanks for the reply.
FYI, I've enabled all the Role Services under Web Server (IIS) in the server before I made my post here. But still, it does not help much. Again, browser such as FireFox allows me to download the image. Any idea?
Thanks and regards,
Kent
ArshadPosted Jul 8, 2009, 6:24 PM
You are Using the Win2008 Server with IIS7.0, thats y its happening.
you can fix it by enable some Feature Under the System Roles. Go to the System Roles in the Windows 2008 Server. There you need to Installed the Static and Dynamic Content option, just Select them and Installed them, After that It will Work.
Regards
Arshad.