Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC: how to prevent a session lock?

I've an application which has some controller's actions calling slow 3rd party web services. These actions are called using AJAX calls from the page.

I can use async controllers to free ASP.NET thread pool, that's great. But what about session? If I use InProc session and a request made to "slow action" the particular user can't make any request to the application because his session is locked by first "slow" call.

In PHP there is a method session_write_close() which I can use as following:

  1. Accept user's request to slow action
  2. Check rights of the user to access controller/action based on session data
  3. Write something to the session if needed
  4. Call session_write_close(). From this point session is closed by this request and any other request from the same user can access it
  5. Make my slow call (maybe in some async way)

I know that I can disable session state on the controller level using [SessionState] attribute, but that's not the solution.

Any ideas?

like image 494
artvolk Avatar asked Sep 04 '12 14:09

artvolk


1 Answers

I think it could be several scenarios.

1) make changes in controller factory and change it to produce contorllers without session or with some custome session implementation

2) try to read this article about sessionless controllers

like image 169
Ph0en1x Avatar answered Sep 23 '22 10:09

Ph0en1x