How to prevent go back in MAUI Blazor?

Andrei Vinogradov 1 Reputation point
2022-06-24T11:47:52.727+00:00

Let's imagine a two pages app, created with MAUI + Blazor Hybrid and running on Android. After user navigates from page1 to page2 I don't want to allow him to go back to first one, until certain conditions are met. In native Android app I could simply override OnBackPressed() in activity. How can I achieve the same with Blazor? I've found a JS hack, it allows me to stay on same page, but it leads to page reload and blink when Back button is pressed, so this is not appropriate for me. So what I want is to completely disable Back button functionality on certain app page, without reloading, blinking and any other side effects when user press it. Like in native app. Is there any way to do that?

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,314 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,576 questions
{count} votes