日期:2014-05-17  浏览次数:20815 次

C# MVC 火狐下载文件时,弹窗中的文件名为乱码
C# MVC 火狐下载文件时,弹窗中的文件名为乱码,但是IE不乱码。
代码如下:
public ActionResult DownloadFile(Guid id)
{
try
{
Document document = DocumentDao.GetDocumentById(id);
string path = string.Format("{0}/{1}", Server.MapPath("/Documents"), document.ArchiveIdentity);
return File(path, "application/octet-stream", Url.Content(document.FileName));
}
catch {
return null;
}
}


------解决方案--------------------
火狐不需要编码,你要区别对待
通过Request\.UserAgent区别不同的浏览器
------解决方案--------------------
你可以参考
http://stackoverflow.com/questions/5826649/returning-a-file-to-view-download-in-mvc
进行更多的控制