[Reason for session deposit in ASP.NET]ASHX, ASPX null (using Flash uploader)

Source: Internet
Author: User

I am using uploadify to upload files, they automatically post to the handler. I then modify the session with the handler that I had setup as a static property in a common class of the website. I then try to access the same session of the ASPX page, and the value is null. I have a feeling this is because of the cookie, but there needs to be a-to-work around this without exposing the sessioni The d in the URL.

Solutions

I found the Answer:when the handler is being called from FLASH (like SWFUpload or uploadify) it does don't pass the current SessionID to the handler. The handler then creates a NEW session. To fix this, do the following:

$ (Selector). Uploadify ({    ' uploadify.swf ',    ' Upload.ashx? Aspsessid=<%=session.sessionid%> '   });

ADD To:Global.asax:

1 voidApplication_BeginRequest (Objectsender, EventArgs e)2 {3     Try4     {5         stringSession_param_name ="Aspsessid";6         stringSession_cookie_name ="Asp.net_sessionid";7         stringSession_value = Request.form[session_param_name]??Request.querystring[session_param_name];8         if(Session_value! =NULL) {Updatecookie (session_cookie_name, Session_value);}9     }Ten     Catch(Exception) {} One } A  - voidUpdatecookie (stringCookie_name,stringcookie_value) - { theHttpCookie cookie =HttpContext.Current.Request.Cookies.Get (cookie_name); -     if(Cookie = =NULL) -     { -HttpCookie Cookie1 =NewHttpCookie (Cookie_name, cookie_value); + Response.Cookies.Add (cookie1); -     } +     Else A     { atCookies. Value =Cookie_value; - HttpContext.Current.Request.Cookies.Set (cookie); -     } -}

If you have form validation, continue to view http://stackoverflow.com/questions/14465314/ how-to-access-session-in-aspx-that-was-modified-in-ashx#comment20148862_14465314

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.