SQL-MisterMagoo / Blazor.PWA.MSBuild

An MSBuild package which adds simple PWA functionality to Blazor client-side Apps
MIT License
96 stars 11 forks source link

Double requests #25

Open newdeal30 opened 4 years ago

newdeal30 commented 4 years ago

Hi MisterMagoo,

Thanks for your package. I know you stopped development on the package, but maybe you can answer me a question. My server-side blazor pwa project uses identity. When i login to the page, the POST requests get send 2 times. When i look at the developer options from the browser i see, that 1 time the POST is send from the form, and one time from ServiceWorker. Do you know that problem?

Thanks and regards Michael

SQL-MisterMagoo commented 4 years ago

Are you sure it is being sent over the wire twice? Here is a sample from the network tab of one of mine

image

You will see lots of cached responses (5th column - size - is greyed out) and two actual network requests (about 612 b each).

On those two requests that made it to the network, you will see two entries in the list as the page requests the network data and the service worker intercepts and performs the actual call.

If you are seeing two actual network requests to the same resource, you might need to modify the service worker to just pass all requests to your identity provider without interruption.

newdeal30 commented 4 years ago

Yes, it is send over the network twice. I get two requests to my controller. One from ServiceWorker.js, and one from the website itself. If i deregister the serviceworker and remove the includes from _Host.cshtml, things are working like they should. Its also not only on the identity login. Same behavior when doing a GET/POST call from my swagger page. Very strange...

PS: I am using ServerSide Blazor vs

newdeal30 commented 4 years ago

I have made a sample project, to see the behavoir. (https://github.com/newdeal30/BlazorPWAApp3) To reproduce: Set a breakpoint in TestController/Get Navigate to https://localhost:5001/swagger Try the method. It should hit 2 times.

Thanks and regards Michael