Uploadify上传插件不兼容FF、Chrome等Netscape浏览器

原因:由于jquery uploadify是借助flash来实现上传的,每一次向后台发送数据流请求时,ie会自动把本地cookie存储捆绑在一起发送给服务器。但FF、chrome不会这样做,他们会认为这样不安全。所以在你需要登录验证后的页面进行上传文件时,FF和chrome获取没有把本地cookie传上去,导致上传失败。

解决办法:在发起页面请求时,验证cookie之前,重新设置cookie,既可正常上传文件

.NET解决方案:在Global.asax文件中加入Application_BeginRequest

protected void Application_BeginRequest()
{            
            if (HttpContext.Current.Request.QueryString["OpType"] != null)
            {
                string c_name = "mycookie";
                HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(c_name);
                if (cookie == null)
                {
                    cookie = new HttpCookie(c_name);
                }
                if (cookie.Value == null)
                {
                    cookie.Value = HttpContext.Current.Request.QueryString["setcookie"];
                    HttpContext.Current.Request.Cookies.Set(cookie);
                }
            }
}
原文地址:https://www.cnblogs.com/yuejin/p/2955508.html