2

For some reason my blazor maui hybrid app is just showing a blank window my routes.razor is this is inside my PasswordManager.App

<Router AppAssembly="@typeof(MauiProgram).Assembly"
    AdditionalAssemblies="new[] { typeof(PasswordManager.Components.Shared._Imports).Assembly }">
    <Found Context="routeData">
        <RouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" />
        <FocusOnNavigate RouteData="@routeData" Selector="h1" />
    </Found>
    <NotFound>
        <PageTitle>Not Found</PageTitle>
        @{
            NavigationManager.NavigateTo("/login", replace: true);
        }
    </NotFound>
</Router>

Main page is just the standard code

<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:local="clr-namespace:PasswordManager.App.Components"
             x:Class="PasswordManager.App.MainPage">

    <BlazorWebView x:Name="blazorWebView" HostPage="wwwroot/index.html">
        <BlazorWebView.RootComponents>
            <RootComponent Selector="#app" ComponentType="{x:Type local:App}" />
        </BlazorWebView.RootComponents>
    </BlazorWebView>

</ContentPage>

Code Behind

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
    }
}

But for some reason, the app is only showing a white screen from this CreateWindow statement.

public partial class App : Application
{
    public App()
    {
        InitializeComponent();
    }

    protected override Window CreateWindow(IActivationState? activationState)
    {
        return new Window(new MainPage()) { Title = "1Password" };
    }
}

When it should be showing my login route, it’s not. The only thing is that my login route is inside PasswordManager.Components.Shared, but it doesn’t give an error saying the route is not found. I picked a blazor class libary

enter image description here

No error shows in the console either

5
  • Are you getting a response back? What is the status code? If you do not get a response it means the server is getting an exception and not returning a response (or server is not completing, somehow hung up). Commented Aug 11 at 9:37
  • @jdweng Maui Blazor Hybrid - the Maui app is the “server”. Commented Sep 2 at 8:22
  • @dotnetdevcsharp isolate the cause. Does it work if login route is directly in main project instead of in separate component? Can you start from a working example, then gradually change it towards your goal? [I haven’t done much with Blazor, so I can’t help with exact details.] Commented Sep 2 at 8:27
  • @ToolmakerSteve : NO, what you are seeing is the response of the server in the client. The server isn't processing the request properly and need to find out root cause. Something is wrong with the request assuming the server code is working properly in other situations. Maybe the issue is a cookie so AP thinks the cookie is valid and not showing a prompt. Maybe solution is to delete the cookie. Commented Sep 2 at 12:06
  • you need to set the CascadingAuthenticationState in your router, and switch the RouteView to a AuthorizeRouteView : <CascadingAuthenticationState><Router ...> <Found ...> <AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(Layout.MainLayout)" /> <FocusOnNavigate ... /> </Found>....</Router></CascadingAuthenticationState> Commented Sep 15 at 10:42

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.