none
Async/await pattern in Mobile Service and infamouse Execute exception in MVC4

    Question

  • Hi all,

    probably I'm missing something really big here, but I cannot manage to make things work...

    I've an ASP.NET MVC4 web application using Azure Mobile Services as a backend.

    Most (if not all) of the AMS API are aycnhronous (i.e: ToCollectionAsync, ReadAsync, etc..) so in my TodoService class I've a bunch of async method with await inside to wait for AMS results.

    Then I've a View in MVC4 (classic Index action) with some @Html.Action method inside the view to render some partial view. The action in the controller are alla async cause they are calling the method of TodoService class that are async cause they are calling AMS methods.

    with this architecture I get Always the infamous: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete

    I know that I cannot execute async child action in ASP.NET MVC4 as expressed here

    So my question is: where am i wrong?? How I can use the "asyncness" of AMS with ASP.NET MVC4?

    Thanks


    JoinJob - From Social Network to Service Network http://www.joinjob.it

    Tuesday, August 27, 2013 8:34 PM

Answers

All replies

  • Have you tried posting this question on the ASP.NET forums? If not let me know and I can find someone who can help you with ASP.NET/MVC.

    Windows Store Developer Solutions #WSDevSol || Want more solutions? See our blog, http://aka.ms/t4vuvz

    Thursday, August 29, 2013 12:25 AM
  • Based on some of the discussion on this Stack Overflow thread, it looks like you need to use a workaround to make these async calls from a child action. The thread has an example of what the workaround would look like. I am also going to follow up with my dev team to find out whether there is something we can be doing here to make this easier (perhaps ConfigureAwait is the answer).
    Thursday, August 29, 2013 1:52 AM
  • I've followed up with some developers on my end and they've confirmed that until ASP.NET MVC supports async child actions, you will need to use workarounds like the one demonstrated in this Stack Overflow thread.
    Thursday, August 29, 2013 8:45 PM
  • Thanks Paul.

    In the meantime I resolved leaving the 4 action as async but instead of calling them inside the parent Action with @Html.Action I call them using jquery + Ajax, so I can even load the page zones independently.


    JoinJob - From Social Network to Service Network http://www.joinjob.it

    Friday, August 30, 2013 9:28 AM