Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:16:12+00:00 2026-06-17T20:16:12+00:00

I am using uploadify to upload files, they automatically post to the handler. I

  • 0

I am using uploadify to upload files, they automatically post to the handler. I then modify the session in the handler that I have setup as a static property in a common class of the website. I then try to access that same session in the aspx page, and the value is null. I have a feeling this is because of cookies, but there needs to be a way to work around this without exposing the sessionid in the url.

ASHX:

public class Upload : IHttpHandler, IReadOnlySessionState, IRequiresSessionState 
{

    public void ProcessRequest(HttpContext context)
    {
        ...
        CMSSession.Current.UploadedFiles.Add(fileName);
    }
}

Session Class:

public class CMSSession
{    
    public static CMSSession Current
    {
        get
        {
            CMSSession session = (CMSSession)HttpContext.Current.Session["__CMSSession__"];
            if (session == null)
            {
                session = new CMSSession();
                HttpContext.Current.Session["__CMSSession__"] = session;
            }
            return session;
        }
    }

    public List<string> UploadedFiles { get; set; }
}

ASPX:

if (CMSSession.Current.UploadedFiles != null)
{
    ...
}
else
{
    IT'S ALWAYS NULL
}

Web.Config:

<sessionState mode="InProc" cookieless="false" /> - causes session to always null in aspx when modified in ashx
<sessionState mode="InProc" cookieless="true" /> - session value is not null, but sessionid is exposed in the url

How do I access & modify the current session within the ASHX file WITHOUT changing cookieless to true and then access the session from the ASPX page?

I have tried using HttpContext and using the context passed into the ASHX…nothing works.

same as this question, but there has to be a more secure way: session set in ashx and get that session on aspx

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:16:13+00:00Added an answer on June 17, 2026 at 8:16 pm

    I found the answer: When the handler is being called from FLASH (like swfupload or uploadify) it does not pass the current sessionid to the handler. The handler then creates a NEW session. To fix this, do the following:

    Your UI: JavaScript:

    $(Selector).uploadify({
        swf: 'uploadify.swf',
        uploader: 'Upload.ashx?ASPSESSID=<%=Session.SessionID%>'   
    });
    

    Add to: Global.asax:

    void Application_BeginRequest(object sender, EventArgs e)
    {
        try
        {
            string session_param_name = "ASPSESSID";
            string session_cookie_name = "ASP.NET_SESSIONID";
            string session_value = Request.Form[session_param_name] ?? Request.QueryString[session_param_name];
            if (session_value != null) { UpdateCookie(session_cookie_name, session_value); }
        }
        catch (Exception) { }
    }
    
    void UpdateCookie(string cookie_name, string cookie_value)
    {
        HttpCookie cookie = HttpContext.Current.Request.Cookies.Get(cookie_name);
        if (cookie == null)
        {
            HttpCookie cookie1 = new HttpCookie(cookie_name, cookie_value);
            Response.Cookies.Add(cookie1);
        }
        else
        {
            cookie.Value = cookie_value;
            HttpContext.Current.Request.Cookies.Set(cookie);
        }
    }
    

    Taken & simplified for uploadify from:
    http://snipplr.com/view/15180/

    You may need to use an authid if using formsauthentication:

    &AUTHID=<%= Request.Cookies[FormsAuthentication.FormsCookieName] == null ? "" : Request.Cookies[FormsAuthentication.FormsCookieName].Value %>
    

    append that to the uploader parameter in the jQuery.

    Then add the following to the global:

    try
        {
            string auth_param_name = "AUTHID";
            string auth_cookie_name = FormsAuthentication.FormsCookieName;
            string auth_value = Request.Form[auth_param_name] ?? Request.QueryString[auth_param_name];
    
            if (auth_value != null) { UpdateCookie(auth_cookie_name, auth_value); }
        }
        catch (Exception) { }
    

    You can now access the same session from the handler (even using the static session object I used above in the question) in IE, Chrome, FF, ect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Uploadify to upload files. Problem is, I need to inform users
I have a plugin for uploading files using jquery uploadify. After calling a method
I'm using Uploadify on localhost to develop a site where users can upload files.
i am using uploadify 2.1.4 in order to upload big files , now, the
I have a form which includes 3 textfields so users can upload files. They
Let's say I need to upload files to a server programmatically using uploading a
Hi am using apache commons upload for uploading files File file=this.getFile();//getter method for the
I used this example (http://reecon.wordpress.com/2010/04/25/uploading-files-to-http-server-using-post-android-sdk/) to upload file from android device to server, it
I'm using a java based uploading construct http://www.javaatwork.com/java-upload-applet/details.html that I tried running over night.
I have been using Uploadify in my PHP application for the last couple months,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.