MVC4 "Cannot await"
asp.net-mvc, asp.net-mvc-4, asynchronous
Solution
Await is applied to the result of a method call that returns a Task.
You cannot call it on News because News isn't a Task. Create a Task and pass your News.Load method to it.
NewsNavigator News = new NewsNavigator();
var newsLoadTask = Task.Factory.StartNew(() => News.Load(page));
await newsLoadTask;
...
Problem
The following code snippet is causing a compilation error that I am hard to understand. Error 1 Cannot await System.Collections.Generic.List'<BusinessLogic.News>' Any suggestions? ``` public class NewsController : Controller { public async Task<ActionResult> Index(int page=1) { NewsNavigator News = new NewsNavigator(); await News.Load(page); ... return View(News); } } public List<News> Load(int page = DefaultPage, int pageSize = DefaultPageSize, string filter = DefaultFilter) { //DBLayer_News ... return LoadedNews; } ```