In this article you will learn how to resolve controller blocking within .NET 4.5 and ASP.NET MVC.
While recently updating an MVC Project, several erratic issues began to start to arise involving inconsistent Controller calls, Controller blocking and apparent deadlocks that were basically rendering the application (and the poor browser handling it) useless. The update was performed in two phases, the first being a simple ASP.NET MVC3 project deployment and the second phase was an update from .NET 4.0 to .NET 4.5, which is where things seemed to go awry and our story begins. Update: A hotfix for this issue has been released, you can read more about it in this follow-up post. The Problem After updating to .NET 4.5, Internet Explorer 9 and below began encountering some strange issues regarding blocked calls to Controllers within the application. The problem was typically occurring when an AJAX request was made to a Controller and during that period an additional request was made to the same controller, which would cause the browser to lock up and typically hang between 1-2 minutes prior to resolving the issues and executing the queued actions. An Example Scenario The following is a set of actions that a user might take to reproduce this issue and should serve as a guideline to determine if this same problem is affecting you:
An Investigation Ensues After continually looking at different things that could be causing this issue such as the AJAX calls themselves, the SessionState settings for the Application, Caching, Temporary Storage (e.g. ViewData, TempData and Session) nothing seemed to make sense. I attempted to use Fiddler however was let down as the traffic would not reveal anything. Developer Tools and Fiddler would both show the AJAX call being made to the Controller Action, which contained a breakpoint, however the breakpoint would never be hit (at least not until the blocking issue was resolved). Here are a few of the attempted fixes:
Finally! Some Classical Salvation! After doing some significant damage to my desk and debating doing the same to my laptop, I continued to rethink what could possibly be going so wrong and then I stumbled upon a suggestion that cured all of these developmental ailments: Change the Application Mode within the Application Pool Settings in IIS from Integrated to Classic. If you are experiencing these same issues with your application and are running into very bizarre and difficult to track down problems regarding Controller blocking, try changing the Mode on your Application Pool within IIS to Classsic Mode. It requires a bit of tinkering when working with MVC to handle routing the old school way: wildcard mappings. I've found that this is the only working solution that I have encountered aside from uninstalling .NET 4.5. Although, I am not quite sure of all of the details as to why IE9, .NET4.5 and AJAX don't seem to want to play nice with one another, I am certainly glad to have this issue resolved. I still believe that this issue could in fact be a bug involving the SessionState and how Internet Explorer 9 interacts with the updated mechanisms to implement asynchronous calls with the recent .NET 4.5 release. If any Microsoft folks are out there and would care to elaborate a bit more on the issue, I would be glad to create a proof-of-concept. Update with a New and Improved Fix! After some follow-up on this issue by several great members of the ASP.NET Forums as well as a few Microsoft employees, we were able to narrow down a more specific fix that involved the uploadReadAhead property within the web.config:
Hands on with ASP.Net MVC - Covering MVC 6