Migrating Blazor wasm with authentication to MAUI

Amjad Khan 21 Reputation points
2022-11-13T04:10:40.137+00:00

I have a standard Blazor wasm hosted app (counter app made by Visual Studio template) with individual accounts for authentication. If I would like to move this app into MAUI so I can use the same app as native windows app, do I need to make any changes to the Blazor authentication? Will the MAUI app able to redirect to login page running on the server side? My goal is to simply run the existing Blazor app with authentication, as a Windows app to cut down any loading time required for standard Blazor wasm websites (Loading...).

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,403 questions
.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,923 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 26,626 Reputation points Microsoft Vendor
    2022-11-14T08:58:16.973+00:00

    Hello @Amjad Khan ,

    Authentication in Blazor Hybrid apps is handled by native platform libraries (iOS/Android/Windows/Mac and so on), which is different from Blazor WASM.
    Furthermore, .NET MAUI apps use Xamarin.Essentials: Web Authenticator: The WebAuthenticator class allows the app to initiate browser-based authentication flows that listen for a callback to a specific URL registered with the app. For more details, you can refer to ASP.NET Core Blazor Hybrid authentication and authorization | Microsoft Learn
    (Note: Xamarin.Essentials is a part of MAUI currently)

    From your description, you want to implement a MAUI app on Windows platform, you can check the Web authenticator in MAUI. At the moment, WebAuthenticator isn't working on Windows, and you can follow the progress at https://github.com/microsoft/WindowsAppSDK/issues/441

    Best Regards,
    Wenyan Zhang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.