FineUI 官方论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

本论坛已关闭(禁止注册、发帖和回复)
请移步 三石和他的朋友们

FineUI首页 WebForms - MVC & Core - JavaScript 常见问题 - QQ群 - 十周年征文活动

FineUI(开源版) 下载源代码 - 下载空项目 - 获取ExtJS - 文档 在线示例 - 版本更新 - 捐赠作者 - 教程

升级到 ASP.NET Core 3.1,快、快、快! 全新ASP.NET Core,比WebForms还简单! 欢迎加入【三石和他的朋友们】(基础版下载)

搜索
查看: 1862|回复: 2
打印 上一主题 下一主题

关于下载的问题

[复制链接]
跳转到指定楼层
楼主
发表于 2012-7-20 04:45:28 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

使用ExtAspNet系在服务器上的资源的时候会报个脚本错误
请问高手如何解决
错误如下图:

下载代码如下:
String orderId = "c07e7675-a5e7-4552-9abe-d2902d24dd5a";
            DataTable model = null;
            DataTable dt = business.SelectOrderDetail(orderId, out model);

            string name = ExeclHelper.ImportOrder(dt, model);
            string filePathName = Server.MapPath("~/File") + "\\" + name;

            if (File.Exists(filePathName))
            {
                FileInfo file = new FileInfo(filePathName);
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name)); //解决中文文件名乱码   
                Response.AddHeader("Content-length", file.Length.ToString());
                Response.ContentType = "appliction/octet-stream";
                Response.WriteFile(file.FullName);
                Response.End();
            }

//FileStream fs = new FileStream(filePathName, FileMode.Open);
            //byte[] bytes = new byte[(int)fs.Length];
            //fs.Read(bytes, 0, bytes.Length);
            //fs.Close();
            //Response.ContentType = "application/octet-stream";
            ////通知浏览器下载文件而不是打开
            //Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(name, System.Text.Encoding.UTF8));
            //Response.BinaryWrite(bytes);
            //Response.Flush();
            //Response.End();

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
沙发
 楼主| 发表于 2012-7-20 04:46:12 | 只看该作者
注释的代码是另外一种方法 都出现脚本错误 请高手给看看 谢谢
板凳
发表于 2013-1-14 05:53:29 | 只看该作者
我知道原因了,要在aspx 的属性设置下
EnableAjax="false"
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|FineUI 官方论坛 ( 皖ICP备2021006167号-1 )

GMT+8, 2024-9-28 19:17 , Processed in 0.045688 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表