473,805 Members | 2,154 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Content-disposition question

Hi. First of all, I *HAVE* to express my annoyance with how badly (at least)
this content thing is documented in MSDN. There's no head, nor tail to it.

Anyway, I have this code in a form named "Download.aspx" . There's all there
is to it - no UI, nothing else. This is all the code.
_______________ _______________ _______________ ______________
'Retrieve the path of the file to download, and create a FileInfo object to
read its properties
Dim strPath As String = Server.MapPath( Request.Params( "File"))
Dim objFileInfo As FileInfo = New FileInfo(strPat h)

'Clear the current output content from the buffer
Response.Clear( )

'Add the header that specifies the default filename for the Download/SaveAs
dialog
Response.AddHea der("Content-Disposition", "attachment filename=" &
objFileInfo.Nam e)

'Add the header that specifies the file size, so that the browser can show
the download progress
Response.AddHea der("Content-Length", objFileInfo.Len gth.ToString())

'Specify that the response is a stream that cannot be read by the client and
must be downloaded
Response.Conten tType = "applicatio n/octet-stream"

'Send the file stream to the client
Response.WriteF ile(objFileInfo .FullName)

'Stop the execution of this page
Response.End()
_______________ _______________ _______________ ______________

In another form I have for instance this anchor: <a
href="Download. aspx?File=/aspnetprojects/vsnet/ThePhile/Old.txt">

As you can see, I'm passing to Download.aspx the file Old.txt. However, the
dialog box shows the filename as being "Download.a spx" instead. Still, if I
press okay, the *CORRECT* file is downloaded, only with the wrong name
(Download.aspx instead of Old.txt). I checked my code in debug, and
objFileInfo is perfect. What can I do ? Is this a known bug ? I searched on
the net and I haven't found any fix or any bug report concerning this
behaviour.

I have IE6 with the latest and greatest updates, and XPSP2.

Thank you,
Alex
Nov 19 '05 #1
1 1475
Please disregard this message - I found the reason - I was missing a ";"
after the word "attachment "

Instead of
Response.AddHea der("Content-Disposition", "attachment filename=" &
objFileInfo.Nam e)

now I have
Response.AddHea der("Content-Disposition", "attachment ; filename=" &
objFileInfo.Nam e)

and it works.

Thanks !
Alex

"Alex Nitulescu" <RE************ ***********@yah oo.com> wrote in message
news:uH******** ******@TK2MSFTN GP10.phx.gbl...
Hi. First of all, I *HAVE* to express my annoyance with how badly (at
least) this content thing is documented in MSDN. There's no head, nor tail
to it.

Anyway, I have this code in a form named "Download.aspx" . There's all
there is to it - no UI, nothing else. This is all the code.
_______________ _______________ _______________ ______________
'Retrieve the path of the file to download, and create a FileInfo object
to read its properties
Dim strPath As String = Server.MapPath( Request.Params( "File"))
Dim objFileInfo As FileInfo = New FileInfo(strPat h)

'Clear the current output content from the buffer
Response.Clear( )

'Add the header that specifies the default filename for the
Download/SaveAs dialog
Response.AddHea der("Content-Disposition", "attachment filename=" &
objFileInfo.Nam e)

'Add the header that specifies the file size, so that the browser can show
the download progress
Response.AddHea der("Content-Length", objFileInfo.Len gth.ToString())

'Specify that the response is a stream that cannot be read by the client
and must be downloaded
Response.Conten tType = "applicatio n/octet-stream"

'Send the file stream to the client
Response.WriteF ile(objFileInfo .FullName)

'Stop the execution of this page
Response.End()
_______________ _______________ _______________ ______________

In another form I have for instance this anchor: <a
href="Download. aspx?File=/aspnetprojects/vsnet/ThePhile/Old.txt">

As you can see, I'm passing to Download.aspx the file Old.txt. However,
the dialog box shows the filename as being "Download.a spx" instead. Still,
if I press okay, the *CORRECT* file is downloaded, only with the wrong
name (Download.aspx instead of Old.txt). I checked my code in debug, and
objFileInfo is perfect. What can I do ? Is this a known bug ? I searched
on the net and I haven't found any fix or any bug report concerning this
behaviour.

I have IE6 with the latest and greatest updates, and XPSP2.

Thank you,
Alex

Nov 19 '05 #2

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

Similar topics

12
3231
by: jonathan.beckett | last post by:
Hi All, For the past few months I have been working on an open source Apache/PHP/MySQL content management system - and have recently made it available for download. It's still very much a work in progress (current release version is 0.4.6), but you should get a very good idea of what it's about by visiting the site (which uses it, funnily enough), or downloading a copy of it and trying it out.
0
2330
by: jonathan.beckett | last post by:
Hi All, I have just made version 0.4.8 of the PluggedOut CMS Content Management System available for download - it's free, and covered by the GPL. It's still very much a work in progress (current release version is 0.4.8), but you should get a very good idea of what it's about by visiting the site (which uses it, funnily enough), or downloading a copy of it and trying it out.
0
2145
by: Scott Abel | last post by:
For immediate release: The Rockley Group Content Management Workshop Series Coming to Atlanta, Seattle, Vancouver, Chicago, Washington, DC, Toronto, and Research Triangle Park Learn more: http://www.rockley.com/workshops.htm The Rockley Group Content Management Workshop Series is designed to
14
2167
by: j1c | last post by:
How can I remove the content in between tags? I have a page that has several custom tags: <!--tag:1--> Content 1 <!--/tag:1--> <br> <!--tag:2--> Content 2 <!--/tag:2--> <br> <!--tag:3--> Content 3 <!--/tag:3--> If I only wanted to see the contents of tag 2 for example, how could I strip out 1 and 3?
1
1557
by: Richard | last post by:
http://dynamicdrive.com/dynamicindex5/linkinfo.htm Using the above script, I have a plan whereby when the main link is active, two different content swaps take place. Column A shows the main menu which is working just fine. In column b I have two subdivisions. Top is for thumbnails, bottom is for description. What I am looking at doing, if possible, is to have the thumbnails and
10
2677
by: clintonG | last post by:
Can somebody direct me to documents or source that supports the use of collapsible content that is collapsed by default when the page is loaded? The secondary objective would of course be cross-browser support.for IE (5-6) and browsers derived from Mozilla (varies). Thank you... <%= Clinton Gallagher
7
8733
by: xkeops | last post by:
Thinking of creating a website, most of the pages will have a general toolbar menu, a content and a footer. The content will be the only one who's gonna change but the rest (header,footer) will remain the same. I am interested to know your opinions/suggestions in finding an easy way of doing it. In asp one could have something like this:
0
2119
by: Managed Code | last post by:
Hello All, Here is my issue and thanks in advance for any assistance. I have a base page with a dropdownlist that fires an event with the selected index. The content page catches the event and sets a connection string to the database. The content page has a simple gridview that should show records from the selected database. Initial content page displays data from correct place. first change of dropdownlist correctly updates content...
1
2284
by: dave8421 | last post by:
Hi, I'm trying to make sense of the definition for "Rendered Content" in current CR for CSS 2.1 Is rendered content what is displayed on the particular media or device? from the definitions, I got the impression that the rendered content is referring to the source document and not the particular
0
9718
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10613
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
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
9186
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
7649
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...
1
4327
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
3
3008
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.