把session_id的值傳到服務端:
當然,你也可以直接在url中將session id傳過去,這樣Http Error 302錯誤就可以得到解決。
問題擴展:MVC使用uploadify3.1 IE下正常firefox、chrome也出現HTTPERROR 302錯誤,有什么解決辦法?
jquery uploadify在ie下可以正常上傳,在實現異步上傳的時候,每一個文件在上傳時都會提交給服務器一個請求。每個請求都需要安全驗證,session 和cookie的校驗。是的,就是這樣。由于jquery uploadify是借助flash來實現上傳的,每一次向后臺發送數據流請求時,ie會自動把本地cookie存儲捆綁在一起發送給服務器。但 firefox、chrome不會這樣做,他們會認為這樣不安全。
首先需要對global.asxa添加如下內容
protected void Application_BeginRequest(object sender, EventArgs e) { /* we guess at this point session is not already retrieved by application so we recreate cookie with the session id... */ 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); }初始化頁面上傳插件代碼如下
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
解決jQuery上傳插件Uploadify出現HttpError302錯誤的方法_jquery
解決jQuery上傳插件Uploadify出現HttpError302錯誤的方法_jquery:之前介紹過jquery uploadify上傳插件的使用方法,我在使用中遇到過Http Error 302錯誤問題,應該會有很多人在使用中遇到過,在此記錄下來: 首先http 302是請求被重定向的意思,這就很容易理解了,如果你的uploadify處理上傳腳本有session驗證,就推薦度:
- 熱門焦點
最新推薦
猜你喜歡
熱門推薦