ASP.net下,如果一个链接是word文件,我希望点击之后,显示让用户保存到本地,而不是直接用IE调用word打开
因为IE调用word很慢,所以客户要求这么做。虽然右击另存是可以的,但是我知道以前ASP下利用组件是可以实现点击后让用户选择是打开还是保存到本地的,ASP.Net下有没有高手做过?顶一下也会给一分哦。能实现的解答,第一位至少50分。
因为IE调用word很慢,所以客户要求这么做。虽然右击另存是可以的,但是我知道以前ASP下利用组件是可以实现点击后让用户选择是打开还是保存到本地的,ASP.Net下有没有高手做过?顶一下也会给一分哦。能实现的解答,第一位至少50分。
Response.AppendHeader("Content-Disposition","attachment;filename="+fi.Name);
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
string fileName = Request.Params["fileName"];
if(string Name !=null)
{
string filePath = @"c:\mydoc"
FileStream MyFileStream = new FileStream(filePath +fileName,FileMode.Open);
long FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fileName,Encoding.UTF8 ));
Response.ContentType="application/ms-word";
Response.BinaryWrite(Buffer);
Response.End();
}
else
{
Response.Write("文件不存在!");
}
System.IO.FileInfo fi=new System.IO.FileInfo(@"c:\我.doc");
Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(fi.Name,System.Text.Encoding.UTF8));
Response.AddHeader("Content-Length",fi.Length.ToString());
Response.WriteFile(fi.FullName);
这个是生成在服务器的各位都想得太复杂了,其实只要做一个_blank的href就可以了