string downfile = filename;
if (Request.UserAgent.ToLower().IndexOf("msie") > -1)
{
downfile = HttpUtility.UrlPathEncode(filename);
}
if (Request.UserAgent.ToLower().IndexOf("firefox") > -1)
{
Response.AddHeader("Content-Disposition", "attachment;filename=\"" + downfile + "\"");
}
else
{
Response.AddHeader("Content-Disposition", "attachment;filename=" + downfile);
}
Response.ContentEncoding = System.Text.Encoding.UTF8;