如我把要下载的文件放在服务器上,www.xxxxx.com/123.mp4 这样打开,报404错误,我想把这个文件(还有其他格式等等)直接下载,如何实现或是哪里设置。

解决方案 »

  1.   

    写一个链接<a></a>指向那个文件就可以吧
      

  2.   

    iis上设置了可以有.mp4 文件类型吗,没有就要指定。还有,不知道你为什么想要搞这种下载模式,直接用ftp不就完事了吗!
      

  3.   


            protected void xiazai_Click(object sender, EventArgs e)
            {
               string path = Server.MapPath(DownloadURL);//path为服务器存放文件的路径 
                FileDownload(path);
            }
            private void FileDownload(string FullFileName)
            {
                System.IO.FileInfo DownloadFile = new System.IO.FileInfo(FullFileName);
                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.UTF8));
                Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
                Response.WriteFile(DownloadFile.FullName);
                Response.Flush();
                Response.End();
            }
      

  4.   

    protected void xiazai_Click(object sender, EventArgs e)
    {
    string path = Server.MapPath(DownloadURL);//path为服务器存放文件的路径 
    FileDownload(path);