473,396 Members | 2,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 1457
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Carter | last post by:
i have a treeview on a webform (.aspx). when the user selects an appropriate node on the tvw. and clicks on a link button, i'm downloading a corresponding file to the client (from the server). so far...
2
by: David Union | last post by:
Hi. I'm posting this here because I don't know exactly what the best group is. This is for an aspx page with Visual Basic as the code-behind page. I am doing very simple code... in the middle...
3
by: Jocelyn Duhaylungsod | last post by:
I have been getting the following server errors sporadically while downloading excel, csv or xml file. Internet Explorer cannot download <file name> from <IP address> "The server returned an...
8
by: Scott C. Reynolds | last post by:
I want to serve a PDF right to a web page (cannot link browser directly to PDF file). Stumbled across Response.WriteFile this morning. On my machine (XP Pro) this worked fine: private void...
2
by: Buddy Ackerman | last post by:
I am creating a ZIP file on the fly and streaming it out to the client using Response.WriteFile(FileName, StartPos, FileSize). Because this ZIP contains files that are on my server and I don't...
1
by: Ryan Pedersen | last post by:
I have been trying to figure out how to transmit a file back to a user using the response.transmitfile or response.writefile method and just not having much success. I have a dell server running...
3
by: Buddy Ackerman | last post by:
I'm trying to write files directly to the client so that it forces the client to open the Save As dialog box rather than display the file. On some occasions the files are very large (100MB+). On...
1
by: David Union | last post by:
I am doing very simple code... in the middle of an http request, i set a filename (with path) and do a Response.WriteFile(filenamewithpath) then Response.End(). I have tried Response.Clear()...
5
by: Khafancoder | last post by:
Hi guys, i am building a FileSharing website, i wanna allow users to be able using download managers such as DAP to download files from webserver but don't allow them to retrive files url......
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.