ASP. net mvc uses jquery uploadify to solve HTTP Error in a non-IE browser

Source: Internet
Author: User

To solve the problem that the uploadify upload control does not work in a non-IE browser, perform the following two steps:

1. Implement the application_beginrequest function in the global. asax file:

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.
Front-end JS modification, pay attention to the red code:

// Upload
VaR auth = "@ (request. Cookies [formsauthentication. formscookiename] = NULL? String. Empty: request. Cookies [formsauthentication. formscookiename]. Value )";
VaR aspsessid = "@ (session. sessionid )";

$ ('# Fileinput1'). uploadify ({
'Upload': '/content/uploadify.swf? Var = '+ new date (). gettime (),
'Script': '/money/importmoneyindue ',
'Folder': '/uploadfiles ',
'Canonicalimg': '/content/cancel.png ',
'Scriptdata': {aspsessid: aspsessid, authid: AUTH },
'Text': '*. xls; *. csv ',
'Filedesc': '*. xls; *. csv ',
'Sizelimmit ': 1024*1024*4, // 4 m
'Multi ': false,
'Oncomplete': Fun

});

In this way, you can.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.