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

  • SEARCH
  • Home
  • 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 8975107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:47:59+00:00 2026-06-15T18:47:59+00:00

I have a scenario where i have a page which opens a dialog on

  • 0

I have a scenario where i have a page which opens a dialog on click of a button, in the opened dialog form on button click i can read a list of data from a selected .txt file and build a query and add the data to some database tables. Since there could be large amount of data this process can take large time because of this the user would not be able to work on the application until the upload completes. Hence to make the upload process Asynk i am using the PageAsyncTask. Below is the code sample, but in the method called in the PageAsyncTask the HttpContext.Current is null hence i am not able to use session handling. Please any guidance on this why would this be null and how can i use the session in this case

   protected void BtnUpload_click(object sender, EventArgs e)
    {
        PageAsyncTask asyncTask1 = new PageAsyncTask(OnBegin, OnEnd, OnTimeout, SessionManager.UserData, true);

        Page.RegisterAsyncTask(asyncTask1);
        Page.ExecuteRegisteredAsyncTasks();
    }

public IAsyncResult OnBegin(object sender, EventArgs e,
            AsyncCallback cb, object extraData)
    {
        _taskprogress = "AsyncTask started at: " + DateTime.Now + ". ";
        uData = extraData as UserData;

        _dlgt = new AsyncTaskDelegate(BeginInvokeUpload);
        IAsyncResult result = _dlgt.BeginInvoke(cb, extraData);

        return result;
    }

private void BeginInvokeUpload()
    {
        string selectedFileName = string.Empty;
        string returnValuePage = string.Empty;
        User teller = new User();
        SessionManager.UserData = uData;
    }



  private void BeginInvokeUpload()
    {
        string selectedFileName = string.Empty;
        string returnValuePage = string.Empty;
        User teller = new User();
        SessionManager.UserData = uData;
    }

public class SessionManager
    {
public static UserData UserData
        {
            get 
            {
                UserData userData = null;
                if (HttpContext.Current.Session["UserData"] != null)
                {
                    userData = HttpContext.Current.Session["UserData"] as UserData;                    
                }
                return userData;
            }
            set 
            {
                 HttpContext.Current.Session["UserData"]=value;                  
            }
        }
}
  • 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-15T18:48:01+00:00Added an answer on June 15, 2026 at 6:48 pm

    The answer is simple : you can not use the session if the HttpContext.Current is null

    So if you need to modify the session you simple can not and the only alternative is to make your totally custom session module/solution.

    If you only need to read some values, then you can pass them when you create your thread.

    And finally the only solution is to not use the thread if you won to manipulate the session variables.

    why this design?

    why MS session did not allow you to handle it out side of a page and inside a thread ? the answer is because is need to lock the session data on page processing – with this lock even if you start a thread and been able to get the session data, will not been able to use it parallel.

    Also if you been able to use the session your self in a thread, then this thread may lock the entire page view process, because I say it again, session is lock the entire page view, and each page that use the same session are not work in parallel

    This lock of session on the entire page is necessary the way the MS session works, and the only way to avoid that is to make a totally custom session solution, and handle special cases with different code.

    The good about that design is that you avoid to make a lot of locking and synchronization by your self on every page call – for example if you disable the session on a page, and use that page for data inserting, if a use make multiple double clicks on the insert, and you do not handle it with synchronization on the insert, you end up with multiple same insertions.

    More about session lock:
    Replacing ASP.Net's session entirely
    Web app blocked while processing another web app on sharing same session
    jQuery Ajax calls to web service seem to be synchronous
    ASP.NET Server does not process pages asynchronously

    Similar question:
    How to get Session Data with out having HttpContext.Current, by SessionID

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

Sidebar

Related Questions

I have a download button in my page from which if the button is
Consider the following scenario: I have a page that can open a dialog (jquery
The scenario: I have an ApEx page which pulls a record from a table.
Scenario: I have a login page which uses ajax to validate a user and
I have the following scenario. I have a search page which is split into
I have a portlet which opens a popup on click of link on it.
I have a page on which is a link. This link opens a second
i have a page, which has 2 links (search, normal button), both redirects are
Here's the scenario - I have a page, within which there is a link
I have the following scenario: Main page Nested page Common JS file (which is

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.