ASP.NET MVC 使用Jquery Uploadify 在非IE浏览器下Http Error的解决方案
2016-01-21 23:55
781 查看
解决Uploadify上传控件在非IE浏览器中不工作,需要做如下2步修改:
1.Global.asax文件中,实现Application_BeginRequest函数:
2. 前台js修改,注意红色代码:
这样就可以了。
出自:http://www.cnblogs.com/shunyao8210/archive/2012/07/02/2572801.html
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 });
这样就可以了。
出自:http://www.cnblogs.com/shunyao8210/archive/2012/07/02/2572801.html
相关文章推荐
- 【深度学习与Theano】LSTM网络-情感分析
- 【深度学习与Theano】LSTM理解
- 【摘要与笔记1】-单层感知器,两层神经网络与深度学习
- 基于三台主机的LAMP,httpd,php-fpm,mariadb,WordPress,phpMyAdmin
- http(17):请求头响应头键值对含义、设置请求头数据,获取请求头数据,获取响应头数据
- [神经网络]1.2-Using neural nets to recognize handwritten digits-Sigmoid neurons(翻译)
- Charles抓包(http/https请求)
- QTcpSocket的读写操作
- Java使用HttpClient库发送请求
- 网络编程02(URL)
- Comet:基于 HTTP 长连接的“服务器推”技术
- 用AFNetworking实现断点续传,暂停,继续
- VMware克隆(复制)后网络配置、CentOS设置静态IP、找不到ipv4地址
- 网络编程(浏览器客户端-自定义服务端)
- datagrid文字省略显示,全文本悬浮显示!_____http://www.educity.cn/wenda/73553.html
- 深入理解WSAAsyncselect网络模型
- 网络编程(TCP-客户端并发登录)
- 数学建模算法(三):神经网络
- CentOS和Ubuntu设置或修改网络配置(IP&网关&DNS)
- 网络请求--Retrofit2使用方法