87,985
社区成员




HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", “*”);
if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
{
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "x-HighCloud-instance,Origin, Content-Type ,Content-Disposition, Authorization, Accept, X-Requested-With");
HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS");
HttpContext.Current.Response.AddHeader("Content-Type", "text/html; charset=utf-8");
HttpContext.Current.Response.AddHeader("Content-Disposition", "11");
HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");
HttpContext.Current.Response.End();
}
var response = this.Request.CreateResponse(HttpStatusCode.OK);
response.Content = new ByteArrayContent(ms.ToArray());
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment");
response.Content.Headers.ContentDisposition.FileName = HttpUtility.UrlEncode(file.RealName);
//response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(contentType);
response.Content.Headers.Add("Content-Type2", "attachment;filename=" + HttpUtility.UrlEncode(file.RealName));
response.Content.Headers.Add("Content-Type", contentType);
return response;
Http.GetSource("/api/File/Download?Account=" + Variable.Account + "&Token=" + item.ID)
.then(function (response) {
if (response.status == 200) {
var Disposition = response.headers("Content-Disposition");
console.log("headers: ", response.headers);
fileName = Common.Method.GetFileNameForStream(response, "文件名称.xls");
var data = new Blob([response.data], { type: response.headers('Content-Type') });
FileSaver.saveAs(data, fileName);
}
});