用ajax请求文件下载当然是可以的,不用有返回值,代码差不多是这样:
try{string FileName = ".//doc//[大家网]Beginning.ASP.NET.2.0.E-Commerce.in.C#.2005.From.Novice.to.Professional[www.TopSage.com].pdf";FileName = ".//doc//Shipping+Advice+Spec++V1.4.xls";FullFileName = Server.MapPath(FileName); //FileName--要下载的文件名 FileInfo DownloadFile = new FileInfo(FullFileName);if (DownloadFile.Exists){Response.Clear();Response.ClearHeaders();Response.Buffer = false;Response.ContentType = "application/octet-stream";Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.ASCII));Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());Response.WriteFile(DownloadFile.FullName);Response.Flush();Response.End();}else{//文件不存在 }}catch{//打开时异常了}