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;
}
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.