473,748 Members | 2,231 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Generating a "virtual file"

Hi

I'm writing a page which outputs CSV data for download. It's all working
fine, setting ContentType to "text/csv", except when the "Open/Save" dialog
appears, the filename shown is "ExportRun.aspx ". Is there any way I can
change this to, e.g., "mydata.csv " without having to generate a temporary
file on the server?

Thanks
Mark
Nov 19 '05 #1
4 1389
Try :

http://support.microsoft.com/kb/260519/en-us

"fname.ext" allows to indicate the name you want to show client side...

Patrice

--

"Mark Rendle" <markdotrendlea tcomputersoftwa redotcom> a écrit dans le
message de news:ue******** *****@tk2msftng p13.phx.gbl...
Hi

I'm writing a page which outputs CSV data for download. It's all working
fine, setting ContentType to "text/csv", except when the "Open/Save" dialog appears, the filename shown is "ExportRun.aspx ". Is there any way I can
change this to, e.g., "mydata.csv " without having to generate a temporary
file on the server?

Thanks
Mark

Nov 19 '05 #2
"Mark Rendle" <markdotrendlea tcomputersoftwa redotcom> wrote in message news:ue******** *****@tk2msftng p13.phx.gbl...
setting ContentType to "text/csv", except when the "Open/Save" dialog appears, the filename shown is "ExportRun.aspx ". Is there
any way I can change this to, e.g., "mydata.csv " without having to generate a temporary file on the server?


Mark,

You need to call AddHeader( ) on the Response to add the "Content-Disposition"
HTTP header and specify a filename (its not one of the standard HTTP headers
that ASP.NET exposes as a property on the HttpResponse class so you have to
use this general-purpose add-a-header method),

Response.AddHea der( "Content-Disposition",
String.Format( "attachment ; filename=\"{0}\ "",
"mydata.csv "
)
);

Watch letting users enter a value for this filename directly, though, since you're
writing it back out to the HTTP protocol's headers (a hacker could easily craft
a malformed header).
Derek Harmon
Nov 19 '05 #3

just add this line to the header
(sample in asp)

Response.AddHea der "Content-Disposition", "attachment ; filename=" &
SaveFileName
"Mark Rendle" <markdotrendlea tcomputersoftwa redotcom> wrote in message
news:ue******** *****@tk2msftng p13.phx.gbl...
Hi

I'm writing a page which outputs CSV data for download. It's all working
fine, setting ContentType to "text/csv", except when the "Open/Save"
dialog appears, the filename shown is "ExportRun.aspx ". Is there any way I
can change this to, e.g., "mydata.csv " without having to generate a
temporary file on the server?

Thanks
Mark

Nov 19 '05 #4
Thanks all for the quick response. Works a treat!

Mark
Nov 19 '05 #5

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

Similar topics

12
13464
by: cppaddict | last post by:
Hi, I know that it is illegal in C++ to have a static pure virtual method, but it seems something like this would be useful when the following 2 conditions hold: 1. You know that every one of your Derived classes will need to implement some method, but implement it differently, and that the base class cannot implement it. This is where pure virtual comes in.
175
8874
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
164
8011
by: Ken Brady | last post by:
I'm on a team building some class libraries to be used by many other projects. Some members of our team insist that "All public methods should be virtual" just in case "anything needs to be changed". This is very much against my instincts. Can anyone offer some solid design guidelines for me? Thanks in advance....
8
4044
by: Asfand Yar Qazi | last post by:
Hi, I have the following header file in my 'everything useful I think of in one place' library: ============= BEGIN CODE SNIPPET =========== /** All classes that derive from this obtain a 'virtual constructor' - ie if the 'clone()' method is called on a polymorphic type, an object of the same (unknown) type is returned. */
0
9355
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9225
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8234
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6790
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4589
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4860
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3296
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.