Warm tip: This article is reproduced from serverfault.com, please click

Blazor not correctly redirecting to controller on IIS

发布于 2020-09-19 19:42:44

I have started on a blazor-webassembly PWA project (.net 5.0-rc1), hosted on asp.net core, and is working Authentication against 3rd party services.
This login flow is based on asp.net core identity.
The flow is as follows:

  • User enters login site and chooses a provider
  • User is redirected to controller, loading provider configuration and redirects user to provider
  • User log in using provider
  • User is redirected to callback, and is logged into system, JWT is generated
  • User is redirected to PWA for handling of JWT.

When developing locally, the above flow works without any issues.
However when deploying to my webhotel, step 2 is redirected to the Blazor application, rather than the controller on the server, causing a "Not found" page.

As the server is hosting the application they share the same base url.
I have tried both a regular link <a href="..."> and navigate with Navigationmanager.NagivateTo(url, forLoad: true);

When shown the "Not Found" page, pressing F5 will result in the same page. However pressing Ctrl+F5 causes the server endpoint to be hit, and the rest of the flow works as intented.

Questioner
Martin Manø
Viewed
0
Martin Manø 2020-11-29 06:32:13

The issue were the serviceworker, catching all requests and sending them to index.html. The answer to this issue can be found in the following: URL Rewrite exceptions for Blazor WebAssembly Hosted deployment