Blazor server app client manager is not working

I have…

  • [ ] Checked the logs and have uploaded a log file and provided a link because I found something suspicious there. Please do not post the log file in the topic because very often something important is missing.

I’m submitting a…

  • [ ] Regression (a behavior that stopped working in a new release)
  • [X] Bug report
  • [ ] Performance issue
  • [ ] Documentation issue or request

Current behavior

Expected behavior

Minimal reproduction of the problem

Environment

  • [ ] Self hosted with docker
  • [x] Self hosted with IIS
  • [ ] Self hosted with other version
  • [ ] Cloud version

Version: [VERSION]

Browser:

  • [x] Chrome (desktop)
  • [ ] Chrome (Android)
  • [ ] Chrome (iOS)
  • [ ] Firefox
  • [ ] Safari (desktop)
  • [ ] Safari (iOS)
  • [ ] IE
  • [ ] Edge

Others:

See the attached image.
I have inject client manager service in blazor component. Service object initialized successfully but GetAsync() method does not responding for long time.

Same service is working fine with Asp .net core 3.1.

Have you tried normal async await?

NEVER, NEVER, NEVER, NEVER use .Result for tasks (if you have not awaited them before).


Tried with normal method and removed .Result.
see the result of the response and it goes infinite when post.Result statement executed.

This problem has actually nothing to do with Squidex. You do not understand how Tasks work.

What you should do is using async…await. In your first example there is even a warning from Visual Studio.

protected override async Task OnInitializedAsync()
{
    var client = cientService.GetContent<Media, ...>("...");

    // ...
   vars posts = await client.GetAsync(...);

   Medias = posts.Items; // To List is not needed.
}

Highly recommended:

Thanks @Sebastian for correcting me.
This is working for me.
Thank’ again…

1 Like

You are welcome, I can also recommend this: https://blog.stephencleary.com/2012/07/dont-block-on-async-code.html

1 Like