473,324 Members | 2,511 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,324 software developers and data experts.

C# ASP.NET download link ...

Hi,

I'm working on a C# ASP.NET web application that generates a table & then lets the user download the results as a tab delimited text file to view in excell. I'm using the following header to set the MIME type to let the browser know to open or download the file:

<% Response.ContentType = "application/vnd.ms-excel"; %>

Now, I.E. lets you open or save the file as DatabaseSearch.xls, but FireFox makes the name DatabaseSearch.aspx by default.


Does anyone know a way to control the name of the file as it shows up in the open/save dialog box? If I could control the name completely, I might make it something like Table.csv and then make it a comma separated value file.

William Deich
Aug 10 '07 #1
4 2908
Frinavale
9,735 Expert Mod 8TB
Hi,

I'm working on a C# ASP.NET web application that generates a table & then lets the user download the results as a tab delimited text file to view in excell. I'm using the following header to set the MIME type to let the browser know to open or download the file:

<% Response.ContentType = "application/vnd.ms-excel"; %>

Now, I.E. lets you open or save the file as DatabaseSearch.xls, but FireFox makes the name DatabaseSearch.aspx by default.


Does anyone know a way to control the name of the file as it shows up in the open/save dialog box? If I could control the name completely, I might make it something like Table.csv and then make it a comma separated value file.

William Deich
I've moved your question to the .NET Forum.
The .NET Articles section is reserved for "how-to" articles and other useful information and is not meant for questions. You should post your question in the .NET Forum section in the future to receive help with your problem. (Blue Menu: Forums -> .NET)

Cheers!

-Frinny
Aug 10 '07 #2
Plater
7,872 Expert 4TB
There is a content-disposition header that you can add to give the file a name.
(Note: Doing this will ALWAYS force the open/save/cancel type box to popup and will override any browser settings to open the file IN the browser window)
Expand|Select|Wrap|Line Numbers
  1. Response.AddHeader("content-disposition", "attachment; filename=" + NameOfFile);
  2.  
Aug 10 '07 #3
Wow!!! Gee, Thanks!!! That really works!!!!!

Hey, do you know what it would look like as a static <%.....%> tag???


Expand|Select|Wrap|Line Numbers
  1. Response.AddHeader("content-disposition", "attachment; filename=" + NameOfFile);
  2.  
Aug 10 '07 #4
Plater
7,872 Expert 4TB
Wow!!! Gee, Thanks!!! That really works!!!!!

Hey, do you know what it would look like as a static <%.....%> tag???
Uhh just put the code inside the <% ... %> tags?
Expand|Select|Wrap|Line Numbers
  1. <% Response.AddHeader("content-disposition", "attachment; filename=" + NameOfFile) %>
  2.  
Aug 10 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: timbratureman | last post by:
I have a txt file in my server. I have to provide to the user 2 links. One link is to download the file and the other one is to display it inside the browser. Is it possible? I made <a...
3
by: Michael | last post by:
I am trying to allow a user to view a PDF in a new window. I currently have this working using the following: <a href="./pdf.do?parameter=01121980" target="top"><b>pdf</b></a> The problem...
14
by: Aaron | last post by:
On my website I have a dynamic link(aspx) to this file 0AX120S.jpg(privacy protection). When a visitor clicks on the link I want them to see my_vacation_pic.jpg (fetch realname from database) is...
0
by: Sarah Akers | last post by:
GgF ----gL5cJ72EqiGIQ0SK65Rz Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html> <head> <style type=3D"text/css">.eyebrow { FONT-WEIGHT: bold; FONT-SIZE: 10px; TE=
0
by: Anne Snow | last post by:
7qs ----bSCMEc0pLIbJxmV9 Content-Type: text/html; Content-Transfer-Encoding: quoted-printable <html><head><style type=3Dtext/css>.eyebrow { FONT-WEIGHT: bold; FONT-SIZE= : 10px;...
0
by: Buddy Ackerman | last post by:
I am trying to implment a file download via a link such that when clicked, instead of starting the default application for that type of file the user will be presented with a download dialog...
0
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
0
by: kain razial | last post by:
ANYOTHER NEEDS ALSO CONTACT ME.I WILL HELP YOU TO GET THAT TEKLA XSTEEL V 12 DOWNLOAD LINK. http://www.sendspace.com/file/zem32r
1
KevinADC
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...
6
mageswar005
by: mageswar005 | last post by:
Hello Guys, I want to Avoid the Save option when i click the download link in php . I just want open and cancel option only, i dont want save option when i click the download link in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.