有这个代码它给了我一个警告:Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
public async Task<ActionResult> Details(Guid id)
{
var calendarEvent = await service.FindByIdAsync(id);
if (calendarEvent == null) return RedirectToAction<CalendarController>(c => c.Index());
var model = new CalendarEventPresentation(calendarEvent);
ViewData.Model = model;
return View();
}
public async Task<RedirectResult> Create(CalendarEventBindingModel binding)
{
var model = service.Create(binding);
await context.SaveChangesAsync();
return this.RedirectToAction<CalendarController>(c => c.Details(model.CalendarEventID));
}
如果我确实添加了await
运算符,我会得到:
Error CS4034 The 'await' operator can only be used within an async lambda expression. Consider marking this lambda expression with the 'async' modifier.
如果我async
像这样添加修饰符:
return this.RedirectToAction<CalendarController>(async c => await c.Details(model.CalendarEventID));
错误是Error CS1989 Async lambda expressions cannot be converted to expression trees
那么如何将强类型的 RedirectToAction(我正在使用 MVC Futures)与异步控制器一起使用?