HTTP响应文件下载在Internet Explorer和Chrome(C#,Asp.net)中不起作用 [英] Http response file download not working in Internet explorer and chrome (C#, Asp.net)

查看:127
本文介绍了HTTP响应文件下载在Internet Explorer和Chrome(C#,Asp.net)中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一种文件下载方法,用于在C#asp.net中将文件从服务器下载到客户端计算机

I write a file download method to download file from server to client machine in C# asp.net

我编写了以下代码:

Response.ContentType = ReturnExtension(System.IO.Path.GetExtension(file.Name));

                    Response.AppendHeader("Content-Disposition", "attachment; filename=" + file.Name);

                    Response.TransmitFile(strRequest);

                    Response.End();

这将在Firefox和Chrome中正常运行,但在IE中则无法运行.

This will work fine in Firefox and Chrome, but not in IE.

推荐答案

尝试在代码上方放置Response.Clear().

这篇关于HTTP响应文件下载在Internet Explorer和Chrome(C#,Asp.net)中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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