<script type="text/javascript">
    var auth = "<% = Request.Cookies[FormsAuthentication.FormsCookieName]==null ? 
string.Empty : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>"; var ASPSESSID = "<%= Session.SessionID %>"; $("#uploadifyLogo").uploadify({ ... formData: { ASPSESSID: ASPSESSID, AUTHID: auth } }); </script>
Global.asax 文件
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); }

 原文地址:http://stackoverflow.com/questions/1729179/uploadify-session-and-authentication-with-asp-net-mvc

相关文章:

  • 2021-09-30
  • 2022-12-23
  • 2021-07-02
  • 2022-02-20
  • 2021-11-06
  • 2021-09-10
  • 2022-01-09
猜你喜欢
  • 2021-09-03
  • 2021-08-07
  • 2022-12-23
  • 2022-02-09
  • 2021-11-30
  • 2021-10-18
相关资源
相似解决方案