2

I need to run async Task Action in a MVC4 controller. In some articles it is stated that my controller needs to inherit AsyncController, and in some it does not.

for example in this sample:

http://www.asp.net/mvc/tutorials/mvc-4/using-asynchronous-methods-in-aspnet-mvc-4 it's not.

  1. Which is it?. In order to run async controller Actions, is it necessary for my controller to inherit "AsyncController"??
1

1 Answer 1

3

You dont need inherit from async controller for asynschrnous actions. Below is the example.

public class HomeController : Controller
{
    public async Task<ActionResult> Index()
    {
         DataServiceClient client = new DataServiceClient();
         var cities = await client.GetCitiesAsync();
        return View(cities);
     }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.