Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • DennisNL 2 posts 22 karma points
    Sep 14, 2013 @ 18:59
    DennisNL
    0

    Asynchronous action Umbraco v6

    Dear all,

    I made an asynchronous Action:

    public async Task<ActionResult> GetMessagesUpdateAsync()
    {
        MessagesService messagesService = new MessagesService();
        var result = await messagesService.GetMessageUpdatesAsync();
        await Task.Delay(30000);
        return Json(result, JsonRequestBehavior.AllowGet);
    }
    

    But whenever I call this action, I always receive the following message:

    System.Threading.Tasks.Task`1[System.Web.Mvc.ActionResult]

    I tried this on a SurfaceController, an AsyncController and a regular Controller. When I run this code in a separate (not umbraco) project, the code just runs fine and returns JSON.

    Also I have tried adding the following line to my web.config on the httpRuntime node:

    targetFramework="4.5"

    As a reference I used: http://www.asp.net/mvc/tutorials/mvc-4/using-asynchronous-methods-in-aspnet-mvc-4

    • Umbraco v6
    • ASP.NET 4.5 / MVC 4

    Am I missing something? Does anyone know if it's possible to have asynchronous actions in Umbraco?

    Thanks!

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Sep 27, 2013 @ 04:38
    Aaron Powell
    0

    I'm experiencing this too, I've seen the problem in other frameworks that wrap around the MVC pipeline but I'm not sure what the fix is.

  • Justin Spradlin 139 posts 347 karma points
    Nov 15, 2013 @ 17:59
    Justin Spradlin
    0

    I just wanted to jump in, I just saw this same behavior in umbraco 6.1.6. Is there any solution yet?

  • DennisNL 2 posts 22 karma points
    Nov 18, 2013 @ 10:02
    DennisNL
    0

    A workaround is to use an attribute to set the session readonly:

    [SessionState(SessionStateBehavior.ReadOnly)]
    public class LiveSessionLessSurfaceController
    {
    }
    

    Of course you can only read your session object, not modify. But it might help you anyway.

  • Chris Wallace 3 posts 23 karma points
    Feb 15, 2014 @ 16:42
    Chris Wallace
    0

    I've been having the same problem as well in Umbraco 7 (fresh install, no upgrade), I tried applying the SessionState attribute as well to my custom Controller but no luck. Has there been any more success with this? 

  • Thiago Custodio 2 posts 22 karma points
    Feb 20, 2014 @ 20:58
    Thiago Custodio
    0

    I'm facing the same problem running Umbraco 7.0.4. I also tried to put the     [SessionState(SessionStateBehavior.ReadOnly)] attribute, but it didn't work. Any ideas?

  • Ole Gade 5 posts 25 karma points
    Mar 28, 2014 @ 14:10
    Ole Gade
    0

    Any news on this one? I'm facing the same problem.

  • Pete Field 4 posts 24 karma points
    Apr 11, 2014 @ 10:20
    Pete Field
    0

    Experiencing the same thing here. 

    I asume it's because Umbraco has hooked into the ASP.Net MVC controller pipeline.

    Any workarounds?

  • Pete Field 4 posts 24 karma points
    Apr 14, 2014 @ 13:42
    Pete Field
    0

    I have managed to get this working in v7 at least.

    More details here http://stackoverflow.com/questions/23006976/async-controller-action-with-umbraco-7-returns-string

  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jul 10, 2014 @ 09:07
  • Shannon Deminick 1524 posts 5270 karma points MVP 2x
    Jul 11, 2014 @ 06:02
    Shannon Deminick
    0

    I've added a work around to that stack overflow thread if you want to have this fixed before the next release is out.

  • Kieron McIntyre 116 posts 359 karma points
    Oct 17, 2015 @ 13:40
    Kieron McIntyre
    0

    I've been experiencing this for quite a while in all my recent Umbraco projects (v6 and v7). They all required async operations but I kept getting the System.Threading.Tasks.Task'1[System.Web.Mvc.ActionResult] output rendered instead of the correct view.

    I figured out how to reproduce this. It seems that when a controller implements IRenderMvcController, any async Index() action will render the code output above, but if you replace this action with one of the same name of the current page's template name, the view is rendered correctly.

    I've written about it here if anyone fancies having a read.

Please Sign in or register to post replies

Write your reply to:

Draft