Open [download file] As a download file and add the message header context. response. addheader ("content-disposition", "attachment; filename ="

Source: Internet
Author: User

<1>

Htmlpage1.htm page

 
<HTML xmlns = "http://www.w3.org/1999/xhtml">  


Download handler1.ashx. CS

Using system; using system. collections. generic; using system. LINQ; using system. web; namespace webapplication3 {// <summary> // download the abstract description of handler1 /// </Summary> public class download handler1: ihttphandler {public void processrequest (httpcontext context) {context. response. contenttype = "image/JPEG"; string filename = context. server. urldecode ("haha.jpg"); // Add a message header. "content-disposition", "attachment; filename = "when the file is opened, it will pop up as a downloaded file. // if this header is not added, the file"/images/111.jpg" will be written to the browser, when the image is displayed in the browser // attachment; filename = "+ filenameits actual download, The 111.jpg file will be taken as the" Haha "alias context. response. addheader ("content-disposition", "attachment; filename =" + filename); // The name of the file to be downloaded. context. response. writefile ("/images/111.jpg"); // ---- Note: writefile} public bool isreusable {get {return false ;}}}}


Zookeeper

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.