The ". html" issue occurs when you download a document when Safari browser downloads

Source: Internet
Author: User

The download code is required to set Response.ContentType = "Application/octet-stream",

Do not set the Application/x-msdownload to Applicatoin/octet-stream (this format represents any binary data),

ContentType is used to define how the user's browser or related device Displays the data that will be loaded.

The code is as follows:

        Private Static voidRendertobrowser (byte[] Bytes, HttpContext context,stringdownloadname) {            if(Context. Request.Browser.Browser = ="IE") {Downloadname= Httputility.urlencode (Downloadname, System.Text.Encoding.UTF8). Replace ("+","%20"); } context. Response.ContentType="Application/octet-stream"; Context. Response.AddHeader ("content-disposition","attachment;filename="+downloadname); Context.            Response.BinaryWrite (bytes); Context.            Response.Flush (); Context.        Response.End (); }

The ". html" issue occurs when you download a document when Safari browser downloads

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.