復制代碼 代碼如下:
if (context.Request.UserAgent.ToLower().IndexOf("msie", System.StringComparison.Ordinal) > -1)//IE浏覽器
{
context.Response.AddHeader("content-disposition", "filename=" + HttpUtility.UrlEncode(fileName));
}
if (context.Request.UserAgent.ToLower().IndexOf("firefox", System.StringComparison.Ordinal) > -1)//firefox浏覽器
{
context.Response.AddHeader("content-disposition", "attachment;filename=\"" + fileName + "\"");
}
else//其他浏覽器
{
context.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
}
context.Response.ContentType = "application/x-xls";