469,625 Members | 1,917 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,625 developers. It's quick & easy.

Response.Writefile problems on 2003 server

Hi all,

I'm trying to force downloads from my page specifically for some powerpoint
and jpeg files. using the following code:

Response.ContentType= "APPLICATION/OCTET-STREAM";
string disHeader= "Attachment; Filename=\"" + sFileName + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload= new System.IO.FileInfo(sDir + sFileName);
Response.WriteFile(fileToDownload.FullName);
Response.Flush();
Response.Close();
Response.End();

My problem is that this works fine on the development (windows XP Pro)
machine but when uploaded to production server (windows 2003 server) it
doesn't work. On the 2003 server it downloads a file with the correct
filename and extension but contains the webpage not the actual file
information!! any ideas??

Thanks
Gav
Jul 27 '07 #1
1 1354
I think that you get exception somewhere between
Response.ContentType line and Response.End

Only that way I see how you can get an Html page.
My bet would be on security exception trying to access file. Or "file not
exists" exception
George.
"Gav" <Ga*@discussions.microsoft.comwrote in message
news:28**********************************@microsof t.com...
Hi all,

I'm trying to force downloads from my page specifically for some
powerpoint
and jpeg files. using the following code:

Response.ContentType= "APPLICATION/OCTET-STREAM";
string disHeader= "Attachment; Filename=\"" + sFileName + "\"";
Response.AppendHeader("Content-Disposition", disHeader);
System.IO.FileInfo fileToDownload= new System.IO.FileInfo(sDir +
sFileName);
Response.WriteFile(fileToDownload.FullName);
Response.Flush();
Response.Close();
Response.End();

My problem is that this works fine on the development (windows XP Pro)
machine but when uploaded to production server (windows 2003 server) it
doesn't work. On the 2003 server it downloads a file with the correct
filename and extension but contains the webpage not the actual file
information!! any ideas??

Thanks
Gav

Jul 27 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Carter | last post: by
2 posts views Thread by David Union | last post: by
3 posts views Thread by Jocelyn Duhaylungsod | last post: by
8 posts views Thread by Scott C. Reynolds | last post: by
2 posts views Thread by Buddy Ackerman | last post: by
1 post views Thread by Ryan Pedersen | last post: by
3 posts views Thread by Buddy Ackerman | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.