473,597 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Forcing a save of a downloaded document

Hi all,

We'd like to take advantage of code we already have for transforming
XML into HTML (using XSLT) for our users to save the HTML as an MS Word
document locally. I've dug around and found the following code to
include in the code behind:

Response.Conten tType = "applicatio n/vnd.ms-word"
Response.AddHea der("Content-Disposition",
"inline;filenam e=someFile.doc" )

As it is, the user gets the document and can open, save, or cancel with
the file dialog box. If s/he opens the document and then tries to
save, the default setting is to save with an HTM extension, which is
what we need to avoid. We want to ensure that the document gets saved
as a DOC file so I'd like to know if there's a way to force the user to
save the file locally (with a DOC extension) before viewing the
document. Any suggestions?

Thanks,

Anthony

Jun 26 '06 #1
4 1527
> As it is, the user gets the document and can open, save, or cancel with
the file dialog box. If s/he opens the document and then tries to
save, the default setting is to save with an HTM extension, which is
what we need to avoid. We want to ensure that the document gets saved
as a DOC file so I'd like to know if there's a way to force the user to
save the file locally (with a DOC extension) before viewing the
document. Any suggestions?


Change your content type to application/octet-stream:

Response.Conten tType = "applicatio n/octet-stream"
Jun 26 '06 #2
Thanks for trying but that didn't work.

Let me further clarify. The content is being dynamically generated as
XML and then transformed using XSLT into HTML which is being dumped
into the Response stream using Response.Write( ) when users click on a
link.

At that time, they're prompted to either "Open," "Save As," or "Cancel"
via the file dialog box. If they select "Save As," the content is
saved into a DOC file without a problem. If the user selects "Open,"
views the file, and then saves, the default extension is HTM.

We don't want to have to rely on users remembering to change the
extension when they save so either we need to:
a) disable the "Open" button on the file dialog, forcing them to
save before viewing OR
b) figure out a way to force word to save the content as a DOC file.

Suggestions are still welcome.

Anthony

Jun 26 '06 #3
> We don't want to have to rely on users remembering to change the
extension when they save so either we need to:
a) disable the "Open" button on the file dialog, forcing them to
save before viewing OR
b) figure out a way to force word to save the content as a DOC file.


OK, I see what you mean now.

I can't be certain, but I presume there is no way of specifying this, as
it's down to the browser what it wants to do with the file. What most sites
do is to provide a description of what the user should do, with small
screenshots, e.g:

1) Click 'Download file' below
2) When you receive a prompt such as the one below, select 'Save As...', do
not select 'Open'
3) Choose a location on your computer to save the file to
4) Browse to the location in 'My Computer' and open the file.
Jun 26 '06 #4
> it's down to the browser what it wants to do with the file

I had figured that the setting were local and there'd be no way to
determine those in the HTTP headers but I'd hoped to hear otherwise ;-)

Thanks for the input.

Jun 27 '06 #5

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

Similar topics

5
7389
by: Poster | last post by:
I have a script, its outputs are in HTML. It displays perferctly in a browser, however when I view source, it gives me the JS scripts, but I want to view the HTML output. Is there a way I can view or save output?
1
2349
by: Oleg Ogurok | last post by:
Hi all, I have a page that's long (>400kb) and therefore takes several seconds to download. I want to put either a progress bar or a simple counter that would show how many percent of the page have been downloaded. Is there a property or a method that returns how many bytes of the page have been downloaded at a given time? Also how do I get the total size of the page in bytes? Thanks -Oleg.
0
1449
by: Matthew Workman | last post by:
Hello all, Does anyone know if you can force the acceptance of a save-as print dialog box programmatically? Specifically, I am opening a document locally, creating a PrintDocument, changing the printer name and then printing it to a file. From there, a save-as box is asking the user to confirm the location but I want it to automatically accept it. Any ideas? I'm stuck in the mudd at the moment. :( Much thanks in advance
5
6869
by: kevin | last post by:
Hi, Any help with this would be really appreciated! I'm trying to download a file from a remote server. The access permissions is okay but the problem I'm facing is that the file is getting downloaded before the Save As dialogue appears. As we will be downloading some large files, it's unpractical to have this. So far the code I have to download the file is
4
4500
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the local machine at a pre defined path (path defined in the registry), and launch the file in its associated application. I think this can be done through ActiveX Controls, but i dont know how to create ActiveX controls in .NET??
4
3829
by: Richard Wilde | last post by:
How do I force an XML document to be downloaded from a web browser to a client? The XML document will come ideally from a dataset but if this is not possible then I can save off the XML document to the server and read it back in to send to the clients browser. I have somethink like this but am struggling to send the XML... With HttpContext.Current.Response
4
2235
by: Jofio | last post by:
I am developing a picture gallery - pictures of landscapes and various other subjects. My site has a left panel consisting of thumbnails of pictures which when clicked displays the corresponding bigger picture of it. Problem is I am trying to keep count of each and every picture downloaded (saved to load computers by visitors). Is it within javaScript realm o do that? I thought of using onLoad event handler ... but not sure. thanks
5
3529
by: Jon Paal | last post by:
how can I bypass the open/save/cancel dialog box and have the document requested open directly in the application associated with the file type ?
4
3656
by: ATS16805 | last post by:
Hi. I wonder if it's possible to "force" a browser to "switch to SSR mode" for any given document. Specifically, I'm looking for a solution, not to a User Agent issue (i think), but a coding idea; a programming "what if..?". i'm not concerned w/ manipulating a browser (i.e. prefs., settings this URL, always view SSR, save), but rather something i would code into the document which would request the browser to display in this mode (i.e....
0
7962
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
7884
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8267
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
8380
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
6681
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
5844
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
2394
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
1
1493
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1229
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.