FireFox中的文件下载问题 [英] File Download issue in FireFox

查看:117
本文介绍了FireFox中的文件下载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个消息传递系统,用户可以在其中相互发送消息,也可以在消息中作为附件发送文件(类似于简单的电子邮件系统).我在firefox中遇到问题,如果文件名在firefox中包含空格(例如,ticket.doc的602_Sign文件),它将与602_Sign.doc保存在一起,但是它应该显示完整的名称,问题在IE和chrome上工作正常,如下是我下载文件的代码

I have make a messaging system in which user can send messages to each other, they can also send files as attachement in message(its like simple email system). I am facing an issue in firefox, if file name contains space(eg 602_Sign File for ticket.doc) in firefox it''ll save with 602_Sign.doc however it should display complete name,issue is working fine on IE and chrome,below is my code for downloading file

public ActionResult Download(string attFileName)
        {
            string FileName = Path.Combine(Server.MapPath("~/MessageAttachmentFiles"), attFileName);
            System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
            response.ClearContent();
            response.Clear();
            Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", System.IO.Path.GetFileName(FileName)));
            response.TransmitFile(FileName);
            response.Flush();
            response.End();
            return null;

        }

推荐答案

尝试这些

http://stackoverflow.com/questions/6248559/如何在asp-net-mvc-3中启用文件下载 [ http://stackoverflow.com/questions/5826649/returning-a- file-to-view-download-in-mvc [ ^ ]

http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Handling-file-downloads-using-ASPNET-MVC.aspx [
Try these

http://stackoverflow.com/questions/6248559/how-to-enable-file-download-in-asp-net-mvc-3[^]

http://stackoverflow.com/questions/5826649/returning-a-file-to-view-download-in-mvc[^]

http://blogs.planetcloud.co.uk/mygreatdiscovery/post/Handling-file-downloads-using-ASPNET-MVC.aspx[^]


尝试以下代码:

Try this code:

public ActionResult Download(string path)
        {
            var Dpath = path.ToString();
            int index = Dpath.LastIndexOf("/");
            string filename = Dpath.Substring(index);
             Dpath = Dpath.Remove(index) + filename;

            if (path != null)
                return File(Dpath, "all", filename);
            else return View("");
        }


这篇关于FireFox中的文件下载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆