Recently I shifted from working with .net 451 to .net 452 and noticed some changes that I thought you might have stumbled upon as well. This problem deals specifically with Asynchronous calls made from MVC4 ASPNET. It was baffling for the first, as I did not quite comprehend as to what might have caused this but then when I found how to fix it, It came as a sweet relief. Not that I don’t want to any longer find out what caused this but, the solution gave me some interim patience not to investigate further.
Now that my solution is working this blog comes symbolic to my curiosity of knowing as to what was so different with net 452.
MVC4 action never needed to be declared asynchronous before despite the repository calls being asynchronous. The ‘task.wait( )’ was a good way around it. Suddenly in net452 this just does not work. What that means is – with the underlying action being asynchronous it would be necessary to have Task<IHttpActionResult> as the return type for the MVC action.
Here is what I was using when I came across the issue.
- Win 10 x64
- Visual Studio with net 452
- MVC4 ASPNET on net 452
- Mongo C# driver 3.2
Here is code that I thought would work but did not.
But then the below is working fine, Not that have anything to complain since the code is much concise now. It then leads me to think if either I have misunderstood something from threading or that MS has changed a few nuts and bolts underneath.
Tell me if you have stumbled on a similar issue and good articles I can read to better comprehend this.