The download dialog box is displayed instead of being opened in the browser.

Source: Internet
Author: User
How to click Download to directly download known types of files from the client browser
Click the link to download the file and click it to download it directly instead of opening it.

When writing a download link, how can I directly download txt, Doc, xls, and other text files without opening the link?

Click "Connect" to download the. txt file directly.

The methods found on the Internet are to use FSO stream to read files and modify the HTTP headers method, which is troublesome and inefficient.

There is a m http headers option in IIS, which can be modified directly.Content-DispositionIsAttachmentYou can.

Example: http://www.mianbi.com/book/a2165bec-a644-4ad3-b2ca-77a8662ff3f6.txt

Microsoft provides a way to override this "stream now" behavior at the server side using a custom HTTP header in IIS. to add the custom header, launch Internet Information Services Manager and expand your web sites to reveal the folder where multimedia content is stored. right-click this folder and choose Properties. click the HTTP headers tab, followed by the Add button.

For the custom header name type:Content-Disposition
For the custom header value type:Attachment

Click OK, click Apply, click OK.

Visit one of the web pages linking to your content download and test the links. You shoshould be presented with the Save As dialog.

There is a catch to this solution. by setting the content-Disposition for the entire folder, your server will pop the Save As dialog box for any file called by a Web browser, including web pages. there are two ways to solve this problem: only store media files in the folder where you modify the content-disposition or set the attribute on-the-fly using code.

From: http://www.jakeludington.com/windows_media_server_admin/20041209_using_custom_http_headers_to_prompt_for_video_file_downloads.html

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.