I have a partial view that tries to retrieve a IEnumerable<Post>
from the database using async...
Method
public static class PostService
{
public static int PostsPerPage = 50;
public static async Task<IEnumerable<Post>> GetRecentAsync(int page = 0)
{
return await entityFrameworkDbContext.Posts
.ToListAsync();
}
}
PartialView
public async Task<ActionResult> Recent(int page = 0)
{
return PartialView(await PostService.GetRecentAsync(page));
}
And then if I try to call it
@Html.Action("Recent", "Post")
I get the following exception
HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete.
Why do I get this error? Shouldn't it work?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…