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);
                }
            }
}

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM