if (File.Exists(filePath))
{
FileInfo fi = new FileInfo(filePath);
context.Response.Clear();
context.Response.ClearHeaders();
context.Response.Buffer = true;
context.Response.Charset = "GB2312";
//判断是否是IE浏览器
if (explorerName.Contains("IE"))
//是IE就对字符串编码
context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpContext.Current.Server.UrlEncode(Path.GetFileName(filePath)));
else
//不是IE就不编码(Firefo、Chrome编码后会显示乱码)
context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + Path.GetFileName(filePath));
context.Response.AppendHeader("Content-Length", model.VideoSize.ToString());
context.Response.ContentType = "application/octet-stream";
context.Response.Filter.Close();
context.Response.TransmitFile(filePath);
context.Response.Flush();
context.Response.End();
}