在我的asp .net应用程序中,我们可以上传doc文件,上传文件后我们可以在浏览器中查看。 它适用于所有浏览器,但是在通过Firefox查看时有一个问题,而单击超链接视图正在下载文件,但文件类型更改为.xml(xml扩展名)。 所以打开它时会有问题。 我们可以通过在firefox设置中进行一些更改来打开它,但在所有客户端机器中这样做都不实用。 它在以前的版本Firefox中工作。 并且还可以在Chrome和IE等所有其他浏览器中工作,并在单击超链接View时以相同的文件类型下载。 如何在firefox中将文件下载为原始文件类型。 请帮帮我
In my asp .net application we can upload doc files and after uploading files we can view it in browser. It is working in all browser, but there is one issue while view through Firefox, while clicking hyperlink view the file is being download, but file type changes into .xml (xml extension). So there is problem while open it. We can open it by making some changes in firefox settings but its not practical to do so in all clients machine. It was working in previous version firefox. And also still working in all other browser like Chrome and IE, and downloads in same file type while clicking hyperlink View. How can I download the files as its original file type in firefox. Please help me
最满意答案
您是否正确将MIME类型设置为Response.ContentType ? 例如:
HttpContext.Current.Response.ContentType = "text/xml";另外我记得Firefox在文件名中有空格问题 - 你必须逃避它们。 所以可能是你的扩展正在被切断。 但那是几年前,可能不再相关了。 你可以检查出来:
不正确: Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", fileName));
正确: Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"", fileName));
Are you setting the MIME type to Response.ContentType correctly? E.g.:
HttpContext.Current.Response.ContentType = "text/xml";Also I remember Firefox having a problem with spaces in filenames - you had to escape them. So it might be your extension is getting cut off. But that was years ago, might not be relevant anymore. You can check it out anyways:
Incorrect: Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", fileName));
Correct: Response.AddHeader("Content-Disposition", string.Format("attachment;filename=\"{0}\"", fileName));
更多推荐
发布评论