Blazor page reload when open external uri

89 Views Asked by At

We are developing an application in C# using .NET 7 Blazor Client. We’re utilizing an external payment system called Adyen with their drop-in component for payments. It’s loaded onto one of the pages via AJAX by specifying the ID of a div tag. One of the payment methods is Swish (a payment solution in Sweden), which opens an external application on the mobile phone via the URI swish://. Everything works except that when this application opens, the Blazor page reloads.

Another issue with Blazor is that we specify a return URL that the Swish application directs the user to upon completing the transaction. This opens in a new tab, despite the address being exactly the same as the tab that opened Swish, resulting in two exactly identical tabs.

We’ve contacted Adyen support, who confirmed this shouldn’t happen. We tested by creating a page in .NET MVC with the exact same code, and the page doesn’t reload, indicating the issue is related to Blazor.

We’ve tested this on:

iOS Safari iOS Chrome Android Chrome Android Firefox

1

There are 1 best solutions below

0
On

URI that start with f.e. swish:// can cause the page to reload if not handled correctly in the your /redirect/-view. I'll need more information to reproduce this issue, could you share a minimal runnable code-snippet where I can reproduce this?

Here are some things that I would check to pinpoint the cause:

  • Are you using Blazor's Javascript Interoperability ([JSImport]/[JSExport]) for the Adyen Drop-in/Components?

  • Are you prerendering Razor components, see documentation. If your app is prerendering, certain actions, such as calling into JavaScript (JS), aren't possible.

  • In your Route templates/Route views (if you're using NavigatoTo), could you try to exclude it from Blazor's routing so it doesn't reload. See documentation NavigateTo and experiment with the forceLoad property. (I don't recommend this as a fix, but it can help you narrow down the problem)

  • When specifying the returnUrl, two tabs are opened most likely due to how you're handling the redirect link (target='_blank'). Have a look whether this is the intended behavior.

This is all I can do without any code snippets for now, let me know if this has helped you