I have a blazor wasm hosted app where a user can create an account by filling a form. When the account is created, an email is sent to the user with a link s/he must follow to confirm his/her ownership of the email address. the link points to an action method in my server. The same server hosts the blazor wasm app AND the APIs.
The problem is, when the user clicks that link, the request isn't sent to the server. Instead, blazor intercepts the call and tries to route to a page.
How can I make this work ? How can I make a link that point to an action in my server actually make it to the server when clicked ? In other words, how to bypass blazor's routing system, if possible ?
Updates:
- I'm using Identity as the backing store (This has nothing to do with the problem I have though).
- I generate the link using the Url property in the base controller
Url.Action("actionName", "controllerName", actionParam, Request.Scheme);
. The link, for now, looks likehttps://localhost:5001/api/user/confirmaemail?confirmationtoken=xyz&useremail=abc
- The Action is a post action.
- When blazor tries to redirect to the page, it obviously can't because I don't have a page with such a route. The content inside the
<NotFound />
component (App.razor file) is therefore displayed.
Note:
This is not an error. This is the normal behaviour of balzor wasm. If an app is hosted at www.foo.com
, then all the calls to foo.com
(www.foo.com/bar
for example) won't actually be made to foo.com
but will be intercepted by blazor and treated as routes to pages in the app. This is, however, blocking me because my APIs have the same base address as the app (the app is, for now, at localhost:5001/
and the APIs at localhost:5001/api/xyz
), hence, blazor is preventing the call to the server when I click the link. The question is how to get arround that ? And if not possible, what other options do I have to implement this flow ?