Why does Blazor Server have the browser call blazor.server.js multiple times?

David Thielen 2,771 Reputation points

Hi all;

I watched a page load using F12 and blazor.server.js is loaded multiple times (see below). I understand the browser loading multiple times because of the ?id=... being different on each. But why does the Blazor code reloading the same Javascript file instead of reading it once and then referencing that loaded file?

thanks - dave


A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,493 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JasonPan - MSFT 4,806 Reputation points Microsoft Vendor

    Hi @David Thielen,

    It's a expected behavior for LongPolling protocol. If you don't want to use LongPolling, you can set it in your Program.cs Like below.

    app.MapBlazorHub(options =>
        options.Transports = HttpTransportType.WebSockets;

    By default, we can use websocket protocol directly, if not works, please kindly check the websocket feature setting in azure portal .

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best Regards


    0 comments No comments