110,565
社区成员
发帖
与我相关
我的任务
分享
try
{
String saveFileName = url;
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.Charset = "UTF-8";
System.Web.HttpContext.Current.Response.Buffer = true;
//EnableViewState = false;
System.Web.HttpContext.Current.Response.ContentType = "application/octet-stream";
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + HttpContext.Current.Server.UrlEncode(filename));
System.Web.HttpContext.Current.Response.WriteFile(saveFileName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.Close();
//System.Web.HttpContext.Current.Response.End();
return 1;
}
catch
{
System.Web.HttpContext.Current.Response.Write("下载发生错误");
return 2;
}