The ". html" error occurs after the Safari browser downloads the document,
To download the Code, set Response. ContentType = "application/octet-stream ",
Do not set it to application/x-msdownload. Change it to applicatoin/octet-stream (this format represents any binary data ),
ContentType defines how your browser or related devices display the data to be loaded.
The Code is as follows:
Private static void RenderToBrowser (byte [] bytes, HttpContext context, string downloadname) {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 ();}