Invoke an AsyncController Action from within another Controller Action?

Posted by Luis on Stack Overflow See other posts from Stack Overflow or by Luis
Published on 2010-04-16T21:31:14Z Indexed on 2010/04/16 21:33 UTC
Read the original article Hit count: 741

Filed under:
|
|
|
|

Hi, I'd like to accomplish the following:

class SearchController : AsyncController
{
    public ActionResult Index(string query)
    {
        if(!isCached(query))
        {
            // here I want to asynchronously invoke the Search action
        }
        else
        {
            ViewData["results"] = Cache.Get("results");
        }

        return View();
    }

    public void SearchAsync()
    {
        // some work

        Cache.Add("results", result);
    }
}

I'm planning to make an AJAX 'ping' from the client in order to know when the results are available, and then display them.

But I don't know how to invoke the asynchronous Action in an asynchronous way!

Thank you very much. Luis

© Stack Overflow or respective owner

Related posts about c#

Related posts about .net-3.5