Home Async PartialView causes "HttpServerUtility.Execute blocked..." exception
Reply: 0

Async PartialView causes "HttpServerUtility.Execute blocked..." exception

user1286
1#
user1286 Published in April 19, 2018, 9:56 am

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?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.599635 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO