在Firefox中下载时,文件类型会变为.xml(File types change into .xml while downloading in Firefox)

编程入门 行业动态 更新时间:2024-10-25 03:22:44
在Firefox中下载时,文件类型会变为.xml(File types change into .xml while downloading in Firefox)

在我的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));

更多推荐

本文发布于:2023-08-06 17:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1454621.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件类型   xml   Firefox   File   downloading

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!