Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Application Deadlocks within MVC using .NET 4.5 and IIS

Upon recently updating an application to .NET 4.5, I began to notice some strange behavior relating to Controllers (and their associated Actions) being "blocked" during AJAX calls from Javascript.

The issues were often inconsistent but would result if a Controller was being accessed through an asynchronous AJAX call and during this requestt another call (through AJAX or traditionally) was made.

This resulted in the original call being "blocked" and it would typically take 1-2 minutes before this "deadlock" was resolved and the actions were executed as intended.

Example Scenario

  • User clicks a link that will temporarily store a value in the
    ViewData to be accessed on the next Request.

  • A Redirect occurs and another Controller is accessed (as it should be) and after loading an AJAX call is made.

  • During this AJAX call (which accesses the ViewData value properly) an additional call is quickly made (such as a User immediately clicking a link to navigate to another Controller). After clicking this link, the "deadlock" will occur and the browser will become unresponsive.

    or

  • The call will be successfully performed (as long as it is not interrupted by another request), but attempted to perform the previous steps will fail.

Additional Information

  • As mentioned, this problem is fairly inconsistent as it will typically execute properly on the first request (the AJAX call) as long as it isn't interrupted. However, if you attempt to make the same call again it will fail.

  • Using the Browser Profiler / Fiddler / Development Tools (F12), the second AJAX call is being made, however it never appears to execute. (Even placing a breakpoint within the AJAX call, however despite the call being made the breakpoint is never hit).

  • This issue occurs ONLY within Internet Explorer 9 or below.

  • The Application is using MVC3, .NET Framework 4.5, IIS 7.5 and was developed in Visual Studio 2012.

Attempted Solutions

  • SessionState - Attempted to use SessionStateBehavior.ReadOnly to avoid any blocking issues that could be occuring on the Controllers in question.

  • Temporary Storage - Used a variety of different means to pass the temporary values across the Controllers, such as ViewData, Session and Cache.

  • ITempDataProvider - Currently considering implementing a provider to handle any temporary values so that the project can be migrated to a more Sessionless solution.


Update

After consulting with several members of the ASP.NET team and a few other community contributors and determined that the issue was in fact a bug within .NET 4.5.

You can read more about the issue in this blog post that I wrote up on this same topic and the updated fix here.

like image 713
Rion Williams Avatar asked Mar 07 '13 19:03

Rion Williams


1 Answers

We have been having similar issues in a test and production environment. We have noticed that it happens only once .net 4.5 is installed. (Removing .net 4.5 fixes the issue.) It does not happen if you debug your application in Visual Studio Development Server or set the AppPool to classic mode. It seems to be related to IIS 7.5 and .net 4.5 with AppPool in integrated mode.

I have found other people having issues, but no definitive answer. IE double postback hangs IIS 7 in Integrated Managed pipeline mode when session is accessed

like image 154
Blane Bunderson Avatar answered Oct 23 '22 00:10

Blane Bunderson