MVC4 ASPNET async action methods on net452

images

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.

  1. Win 10 x64
  2. Visual Studio with net 452
  3. MVC4 ASPNET on net 452
  4.  Mongo C# driver 3.2

Here is code that I thought would work but did not.

gist of the code

GistMvcAspAsyncContr

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.

GistMvcAspAsyncContr_working

Tell me if you have stumbled on a similar issue and good articles I can read to better comprehend this.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

Up ↑

%d bloggers like this: