Obtain remote images by downloading files

Source: Internet
Author: User
           //  Response. setheader ("content-disposition", "inline; filename=test1.doc ");  //  Open with IE for online browsing Response. setheader ( "  Content-Disposition  " , "  Attachment; filename=test1.doc  " ); //  Download Method, download, open without a browser Response. contenttype = " Application/octet-stream  "  ; Response. addheader (  "  Content-Disposition  " , "  Attachment; filename=ciwong.doc  "  );  String Strdoc = This . Renderview ( "  View  " ,New Examination. Mapping. Entities. Examination () {examinationid = Id}); response. contenttype = "  Application/MS-Doc  "  ; Response. Write (strdoc); response. Flush (); response. End (); response. Close (); 
// Download the Remote Image
Public StaticSystem. Drawing. Image downimg (StringURL) {webrequest wreq=Webrequest. Create (URL); wreq. Timeout=10000; Httpwebresponse wresp=(Httpwebresponse) wreq. getresponse (); stream s=Wresp. getresponsestream (); system. Drawing. Image img=System. Drawing. image. fromstream (s); IMG. Save (filename, imageformat. JPEG); IMG. Dispose (); S. Dispose ();ReturnIMG ;}

 

// Response. setheader ("content-disposition", "inline; filename=test1.doc"); // open the file in IE
Response. setheader ("content-disposition", "attachment; filename=test1.doc"); // download method, which can be opened without a browser
Response. contenttype = "application/octet-stream ";
Response. addheader ("content-disposition", "attachment; filename=ciwong.doc ");
String strdoc = This. renderview ("View", new examination. Mapping. Entities. Examination () {examinationid = ID });
Response. contenttype = "application/MS-Doc ";
Response. Write (strdoc );
Response. Flush ();
Response. End ();
Response. Close ();

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.