question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Asp.Net Core Blazor SignalR not working as expected in IIS

See original GitHub issue

(Visual Studio 2019. Blazor WebAssembly with .NET 5.0. NuGget packages updated. WebSocket enabled) Hi I have a .NET 5 blazor wasm project, it works on local perf, but when I publish it on IIS not working as expected.

https://github.com/equirev73/Languages

After a few minutes it waits for some time and then it no longer navigates. In Chrome + F12 I see requests “wss” such as IIS Express. But now its status is pending. Prim

LanguagesList.razor (only code)

@code {
      List<ProgramingLanguages> languages;
      private HubConnection hubConnection;

      protected override async Task OnInitializedAsync()
      {
          hubConnection = new HubConnectionBuilder()
              .WithUrl(NavigationManager.ToAbsoluteUri("/languageshub"))
            .Build();

          hubConnection.On("ReceiveMessage", () =>
          {
            CallAllLanguages();
            StateHasChanged();
          });

          await hubConnection.StartAsync();
          await GetAllLanguages();
      }

      private void CallAllLanguages()
      {
          Task.Run(async () => await GetAllLanguages());
      }

      protected async Task GetAllLanguages()
      {
          languages = await   HttpClient.GetFromJsonAsync<List<ProgramingLanguages>>("api/ProgramingLanguages");
          StateHasChanged();
      }

      public void Dispose()
      {
          _ = hubConnection.DisposeAsync();
      }
}

Thanks in advance

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
equirev73commented, Jan 5, 2021

Thank you @BrennanConroy . I was checking on Develpment and IIS. Now it works even without SSL. I was very worried. Now I trust Blazor Wasm + SignalR again. I will study the tutorial that you mentioned. Maybe one day I can help someone. If an error should appear, I will be file an issue there. So they take a look at it.

Thank you @BrennanConroy again. Thank you @Ariansh . Thank you @pranavkm.

1reaction
BrennanConroycommented, Jan 4, 2021

@equirev73 The error you showed above about the “delegate target no longer available” is an issue with the WASM Runtime at https://github.com/dotnet/runtime. If you have a small consistent repro it might be a good idea to file an issue there for them to look at.

As far as getting rid of that error, you are missing @implements IDisposable from your LanguageList.razor page which means the SignalR client is never disposed and you have a bunch of background WebSocket clients running (which is part of the reason for the error you see).

Side-note: You can use DisposeAsync in 5.0 with @implements IAsyncDisposable and we have a tutorial for Blazor Wasm + SignalR at https://docs.microsoft.com/aspnet/core/tutorials/signalr-blazor-webassembly?view=aspnetcore-5.0&tabs=visual-studio

Read more comments on GitHub >

github_iconTop Results From Across the Web

Blazor Client Side Signalr not working when Hosting to IIS
When hosting my Blazor Client Side application to IIS the signalr is not working. In visual studio with IIS express it work as...
Read more >
SignalR Troubleshooting
Take a look at ASP.NET Core SignalR. This document describes common troubleshooting issues with SignalR. Software versions used in this topic.
Read more >
Solved SignalR not working after deploying in IIS
Please my SignalR App works well locally but after deploying to IIS win 10 it doesn't work. I have tried to activate web...
Read more >
Build Real-time Applications with ASP.NET Core SignalR
Web apps are expected not only to function properly, but they need to do so with a great user experience. Users expect applications...
Read more >
Four reasons why your ASP.NET Core application is not ...
Problem #1: Permissions ... So you've published your ASP.NET Core application. You've set up a website in IIS pointing to your published folder....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found