473,381 Members | 1,452 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,381 software developers and data experts.

File Download Functionality Different on Dev and Test Servers

Basically I have a link that opens my download page and the querystring
identifies the type of 'template' Excel spreadsheet has asked to download.
The download page reads the querystring, identifies the template required
then uses Response.AppendHeader to amend the response to create the file
download dialogue. On my local machine this works fine and the download
dialogue correctly identifies the file name and type attempting to be
downloaded. However, when this is ported to the Test web server the download
dialogue asks if I want to save or open the Download.aspx page, not the xls
file that should be targetted. To further confuse me, if you save this file,
open it in a text editor, remove the html elements of it, leave the encoded
elements, (square blocks, hex etc.), and save this as an xls file from the
text editor MS Excel opens the saved file correctly and it is in fact the
file that was attempted to be downloaded.

To me it appears that on my dev machine the download works fine and streams
the excel file to be saved locally, but on the test server it's streaming
both the page and the Excel file for downloading. I've included the basics of
the code below and was wondering if anyone has a way to explain this
behaviour and how to fix it...

private void Page_Load(object sender, System.EventArgs e)
if( Request.QueryString["filetype"] != null )
// A file download has been requested
string downloadType =
if( downloadType ==
FRSessionParameterName.DownloadSRPTemplate.ToUpper () )
string filePath =
ConfigurationSettings.AppSettings["templatesDir"] +
"/" +
ConfigurationSettings.AppSettings["stormReturnPeriodsDir"] +
"/" +

filePath = this.MapPath( filePath );
DownloadFile( filePath, true );
// Unknown file type - shouldn't happen

private void DownloadFile( string path, bool forceDownload )
string name = Path.GetFileName( path );
string ext = Path.GetExtension( path );
string type = "";

// set known types based on file extension
if ( ext != null )
switch( ext.ToLower() )
case ".htm":
case ".html":
type = "text/HTML";
case ".doc":
case ".rtf":
type = "Application/msword";
case ".xls":
type = "Application/vnd.ms-excel";
type = "text/plain";
if ( forceDownload )
Response.AppendHeader( "content-disposition", "attachment;
filename=" + name );

if ( type != "" )
Response.ContentType = type;

// Force file to download

Nov 19 '05 #1
0 1717

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: Mel | last post by:
when downloading files from my site, when file types are known (i.e *.doc) browsers open the file for viewing. is there a way to disable that and just present the save as dialog (same as for...
by: Søren Reinke | last post by:
Hi there I am having a little problem. At the company i work in, we are working on a bunch of applications for a server, and also webservices and aspx pages. The main problem is i would...
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
by: OliviuG | last post by:
I have export to xls functionality in asp.net web form, implemented like this: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=InvChangeHistory.xls");...
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
by: clintonG | last post by:
To all Microsoft partners and customers who have been unable to download recently or access ASP.NET documentation from the msdn2 website and for all of those customers who have been lied to and...
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.