MVC ActionResult trigger Async Task before return View()

I'm trying to achieve something like this:

[HttpPost]
public ActionResult PostData()
{
    // 1. Need to trigger an async operation for some long processes
    // Trying to trigger SideProcess() async controller

    // Return to view to allow user do other stuff without waiting for above process to complete
    return View("Listing", "Users");
}

public async Task<ActionResult> SideProcess()
{
    ...
}

Can I use async task method like above? Because I definitely have to call PostData() first on a button click. Otherwise most likely I have to use a different method.



Read more here: https://stackoverflow.com/questions/66328809/mvc-actionresult-trigger-async-task-before-return-view

Content Attribution

This content was originally published by Koo SengSeng at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: