Search code examples
c#debuggingblazorwebassembly

Dev Tools shows endless network loop for Blazor deployed application


I am working on a blazor application. When I debug locally, I have no issues.

However, when I deploy it to IIS (locally or on a server), the network tab of dev tools in Chrome shows a endless loop.

local screenshot: enter image description here

deployed in IIS screenshot (thousands of requests and growing):

enter image description here

My question(s): how can I figure out where this call is coming from? Can I turn of the encoding or something?


Solution

  • I added logging to my razor page events, and found the loop.

    The OnAfterRenderAsync called another method which included a StateHasChanged. This resulted in an endless loop.

    Reading about the component lifecycles here: https://blazor-university.com/components/component-lifecycles/

    We can see OnAfterRenderAsync fires any time the state changes. So I had to basically remove any logic from OnAfterRenderAsync that would cause the state of the component to change.