惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Stack Overflow Blog
Stack Overflow Blog
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
Microsoft Security Blog
Microsoft Security Blog
Microsoft Azure Blog
Microsoft Azure Blog
J
Java Code Geeks
D
DataBreaches.Net
U
Unit 42
P
Proofpoint News Feed
I
InfoQ
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
博客园 - Franky
博客园_首页
IT之家
IT之家
博客园 - 叶小钗
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 【当耐特】
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志

博客园 - IT爱好者

C# 自定义打印 C# 打印,不显示打印进度对话框 如何解决迅雷插件导致IE10崩溃的问题 c#操作access,update语句不执行的解决办法 解决:System.Data.SqlClient.SqlError: FILESTREAM 功能被禁用 服务器“**”上的MSDTC不可用的解决办法 通过Package Manager Console 向VS2010安装 EFCodeFirst 删除SVN遗留的无用文件 解决"System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本" 修改IIS默认的localhost名称 IIS服务器应用程序不可用的解决办法 使用XML与远程服务器进行交互 小米手机指令大全 Java与.NET DES加密解密互转 获取执行SQL语句的返回结果 ASP.NET中如何向页面写入JavaScript脚本内容 Oracle自增列创建方法 ASP.net中用JSON序列化对象 android Listview 拖动时背景为黑色问题
ASP.NET MVC 使用Jquery Uploadify 在非IE浏览器下Http Error...
IT爱好者 · 2012-07-02 · via 博客园 - IT爱好者

解决Uploadify上传控件在非IE浏览器中不工作,需要做如下2步修改:

1.Global.asax文件中,实现Application_BeginRequest函数: 

 

void Application_BeginRequest(object sender, EventArgs e)
        {
            try
            {
                string session_param_name = "ASPSESSID";
                string session_cookie_name = "ASP.NET_SessionId";
                if (HttpContext.Current.Request.Form[session_param_name] != null)
                {
                    UpdateCookie(session_cookie_name, HttpContext.Current.Request.Form[session_param_name]);
                }
                else if (HttpContext.Current.Request.QueryString[session_param_name] != null)
                {
                    UpdateCookie(session_cookie_name, HttpContext.Current.Request.QueryString[session_param_name]);
                }
            }
            catch { }

            try
            {
                string auth_param_name = "AUTHID";
                string auth_cookie_name = FormsAuthentication.FormsCookieName;
                if (HttpContext.Current.Request.Form[auth_param_name] != null)
                {
                    UpdateCookie(auth_cookie_name, HttpContext.Current.Request.Form[auth_param_name]);
                }
                else if (HttpContext.Current.Request.QueryString[auth_param_name] != null)
                {
                    UpdateCookie(auth_cookie_name, HttpContext.Current.Request.QueryString[auth_param_name]);
                }
            }
            catch { }
        } 

        private void UpdateCookie(string cookie_name,string cookie_value)
        {
            HttpCookie cookie =HttpContext.Current.Request.Cookies.Get(cookie_name);
            if(null== cookie)
            {
                cookie =new HttpCookie(cookie_name);
            }
            cookie.Value= cookie_value;
            HttpContext.Current.Request.Cookies.Set(cookie);}

        } 


2. 前台js修改,注意红色代码:

//upload
        var auth = "@(Request.Cookies[FormsAuthentication.FormsCookieName]==null?string.Empty:Request.Cookies[FormsAuthentication.FormsCookieName].Value)";
        var ASPSESSID = "@(Session.SessionID )";

        $('#fileInput1').uploadify({
            'uploader''/Content/uploadify.swf?var=' + new Date().getTime(),
            'script''/Money/ImportMoneyInDue',
            'folder''/UploadFiles',
            'cancelImg''/Content/cancel.png',
            'scriptData':  { ASPSESSID: ASPSESSID, AUTHID: auth },
            'fileExt''*.xls;*.csv',
            'fileDesc''*.xls;*.csv',
            'sizeLimit'1024 * 1024 * 4//4M
            'multi'false,
            'onComplete': fun

        }); 

这样就可以了。