//post 请求报文体的接收方式
HttpContext.Current.Response.ContentType = "application/json";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.IO.Stream inputStream = HttpContext.Current.Request.InputStream;
System.Text.Encoding encoding = HttpContext.Current.Request.ContentEncoding;
System.IO.StreamReader streamReader = new System.IO.StreamReader(inputStream, encoding);
string json = streamReader.ReadToEnd();
//得到错误信息
TH.SampleAccept.ServiceImpl.ResData res = daSErvice.GetPDFFile(json, context);
if (res.StatusCode == 200)
{
string fullPath = context.Server.MapPath("~///") + res.FilePaths.FileName;
string fileName = Path.GetFileName(fullPath);
FileInfo fileinfo = new FileInfo(fullPath);
context.Response.Clear(); //清除缓冲区流中的所有内容输出
context.Response.ClearContent(); //清除缓冲区流中的所有内容输出
context.Response.ClearHeaders(); //清除缓冲区流中的所有头
context.Response.ContentEncoding = System.Text.Encoding.UTF8;
context.Response.AddHeader("Content-type", "text/html;charset=UTF-8");
context.Response.ContentEncoding = System.Text.Encoding.UTF8; //获取或设置输出流的 HTTP 字符集
context.Response.Buffer = true; //该值指示是否缓冲输出,并在完成处理整个响应之后将其发送 filename* = UTF-8''"+name
//context.Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
context.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(fileName)));
context.Response.AddHeader("Content-Length", fileinfo.Length.ToString());
context.Response.AddHeader("Content-Transfer-Encoding", "binary");
context.Response.ContentType = "application/unknow"; //获取或设置输出流的 HTTP MIME 类型
context.Response.TransmitFile(fullPath);
}