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 7408463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:55:16+00:00 2026-05-29T05:55:16+00:00

I have a long running (4-10 second) MVC action that runs a report from

  • 0

I have a long running (4-10 second) MVC action that runs a report from an AJAX call. While it’s running users can change the parameters and run something else, so I cancel the AJAX request before making another one.

So, for instance (example in jQuery but the problem happens regardless):

// If we have an active request and it's not complete
if(dataRequest && dataRequest.readyState != 'complete') 
{
    dataRequest.abort();
}

dataRequest = $.ajax(...);

Client side this appears to work fine, but the cancelled request is still running on the server. For instance if the report takes 10 seconds, and I cancel one and start the other then the second request takes 20 seconds.

I think this is due to the session level locking:

[If] two concurrent requests are made for the same session (by using
the same SessionID value), the first request gets exclusive access to
the session information. The second request executes only after the
first request is finished.

So the second request can’t access the session until the first one finishes. Using asynchronous MVC actions doesn’t seem to get around this as the action still needs to be able to make changes to the session.

Is it possible to stop one action and start the next without using AsyncController or [SessionState(SessionStateBehavior.ReadOnly)]?

If it isn’t are both required?

  • 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-05-29T05:55:17+00:00Added an answer on May 29, 2026 at 5:55 am

    As it turns out the complete answer required two things:

    Firstly (thanks Darin for confirming it) the session essentially locks the pages to be executed one after the other. Further investigation has pointed to this being a more general problem with ASP.Net sessions – they just can’t handle optimistic concurrency.

    Secondly the cancelled request needs to check whether the client is still connected. There are situations where you might want to continue (like a fire and forget ASP action) but in this case if the client’s no longer waiting for the report there’s no point us continuing to process it.

    This is available as a property of the response: this.Response.IsClientConnected

    So to effectively cancel my server side action when jQuery requested it I had to write my own session handler and add regular checks against this.Response.IsClientConnected.

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

Sidebar

Related Questions

i have long running task that gets called using jquery ajax. i am using
I have some (potentially) long-running ajax calls that I would like to abort if
I have a long-running SP (it can run for up to several minutes) that
I have a long-running multithreaded program, and I'd like to occasionally like to call
I have a long-running cleanup operation that I need to perform in onDestroy() of
I occasionally have some long running AJAX requests in my Wicket application. When this
I have a somewhat-long-running stored procedure being called from a PB application. I want
I have a long-running process that must run every five minutes, but more than
I have a Perl script that executes a long running process and observes its
I have a long-running Task that I've implemented using the Task Parallel Library. When

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.