对于某些格式文档,使用超链接的方式,不能实现正常下载,如果需要下载,可以通过以下代码实现:
protected void DownloadFile(string filename)
{
int intStart = filename.LastIndexOf("//") + 1;
string saveFileName = filename.Substring(intStart, filename.Length - intStart);
Response.Clear();
Response.Charset = "utf-8";
Response.Buffer = true;
this.EnableViewState = false;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(saveFileName, System.Text.Encoding.UTF8));
Response.WriteFile(filename);
Response.Flush();
Response.Close();
Response.End();
}
以上代码在VS.Net测试通过。