日期:2014-05-16  浏览次数:21224 次

想在iis的下载文件的http头部分带有filename=文件名这个项
应该怎样配置

------解决方案--------------------
自己写代码来实现文件下载,而不是直接访问文件所在的URL

C# code

        String value = "This is the test value"; //你也可以读取文件内容到value变量
        Response.Clear();
        Response.ClearHeaders();
        Response.Buffer = false;
        Response.ContentType = "application/octet-stream";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.AddHeader("CONTENT-LENGTH", value.Length.ToString());
        Response.AddHeader("Content-Disposition", "attachment; filename=download.txt");
        Response.CacheControl = "public";
        Response.Write(value);
        Response.Flush();