Mime Type supplement

Source: Internet
Author: User

Content-disposition is an extension of the mime protocol. Some browsers may not support content-Disposition because security considerations are not standardized, such as ie4.01.
You can set the HTTP header to implement some functions.

 

1. Set the value to attachment to ensure that the "File Download" dialog box is displayed when the client accesses it. (Some mime-type files (for example, *. gif; *. txt; *. htm) are displayed in IE by default. A dialog box cannot be displayed)

2. If the filename attribute is not set in the header, the file name can be specified during client download.

3. Set the value to inline so that the file is displayed in the browser instead of the file download dialog box.

CodeExample:

Response. setheader ("content-disposition", "attachment; filename =" + filename ).

// Content-disposition is the attribute name.

// Attachment indicates downloading as an attachment. If you want to open it on the page, change it to inline.

// Filename specifies the downloaded file name. If this parameter is not specified, the file is determined by the client.

// If it is a Chinese character, garbled characters will appear. There are two solutions:

// 1. Use the filename = new string (filename. getbytes (), "ISO8859-1") Statement

// 2. Use the filename = httputility. urlencode (filename, system. Text. encoding. utf8) Statement

 

In C #, The system. Web. Mime space provides a large number of mime enumeration types, including in the system. Web. Mail. dll file.

Dispositiontypenames enumerated dispositiontype, (Attachment/inline)

 

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.