You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# .NET MAUI Blazor Hybrid and Web App with ASP.NET Core Identity
@@ -37,7 +37,7 @@ For prerequisites and preliminary steps, see <xref:blazor/hybrid/tutorials/maui>
37
37
The sample app is a starter solution that contains a native, cross-platform MAUI Blazor Hybrid app, a Blazor Web App, and a Razor class library (RCL) that contains the shared UI (Razor components) used by the native and web apps.
38
38
39
39
1. Clone this repository or download a ZIP archive of the repository. For more information, see [How to download a sample](xref:fundamentals/index#how-to-download-a-sample).
40
-
1. Make sure you have [.NET 9 and the MAUI workload installed (.NET MAUI documentation)](/dotnet/maui/get-started/installation).
40
+
1. Make sure you have [the latest .NET installed with the MAUI workload](/dotnet/maui/get-started/installation).
41
41
1. Open the solution in Visual Studio (2022 or later) or VS Code with the .NET MAUI extension installed.
42
42
1. Set the `MauiBlazorWeb` MAUI project as the startup project. In Visual Studio, right-click the project and select **Set as Startup Project**.
43
43
1. Start the `MauiBlazorWeb.Web` project without debugging. In Visual Studio, right-click on the project and select **Debug** > **Start without Debugging**.
@@ -52,7 +52,7 @@ The sample app is a starter solution that contains a native, cross-platform MAUI
52
52
53
53
## Shared UI
54
54
55
-
The shared UI is in the `MauiBlazorWeb.Shared` project. This project contains the Razor components that are shared between the MAUI and Blazor Web App projects (Home, Counter and Weather pages). The `Counter`component and `Weather`component are protected by [`[Authorize]` attributes](xref:Microsoft.AspNetCore.Authorization.AuthorizeAttribute), so users can't navigate to them unless they're logged into the app.
55
+
The shared UI is in the `MauiBlazorWeb.Shared` project. This project contains the Razor components that are shared between the MAUI and Blazor Web App projects (Home, Counter, and Weather pages). The `Counter` and `Weather`components are protected by [`[Authorize]` attributes](xref:Microsoft.AspNetCore.Authorization.AuthorizeAttribute), so users can't navigate to them unless they're logged into the app.
56
56
57
57
In the [Razor directives](xref:blazor/components/index#razor-syntax) at the tops of the `Counter` component (`MauiBlazorWeb.Shared/Pages/Counter.razor`) and `Weather` component (`MauiBlazorWeb.Shared/Pages/Weather.razor`) files:
### MAUI Authentication State Provider (`MauiAuthenticationStateProvider`)
149
149
150
-
The `MauiAuthenticationStateProvider` class is responsible for managing the user's authentication state and providing the <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationState> to the app. The `MauiAuthenticationStateProvider` class uses an <xref:System.Net.Http.HttpClient> to make requests to the server to authenticate the user. For more information, see <xref:blazor/hybrid/security/index?pivots=maui>.
151
-
152
-
In `MauiBlazorWeb/Services/MauiAuthenticationStateProvider.cs`:
LoginFailureMessage="Invalid Email or Password. Please try again.";
185
-
LoginStatus=LoginStatus.Failed;
186
-
}
187
-
}
188
-
catch (Exceptionex)
189
-
{
190
-
Debug.WriteLine($"Error logging in: {ex}");
191
-
LoginFailureMessage="Server error.";
192
-
LoginStatus=LoginStatus.Failed;
193
-
}
194
-
195
-
returnauthenticatedUser;
196
-
}
197
-
```
150
+
The `MauiAuthenticationStateProvider` class (`MauiBlazorWeb/Services/MauiAuthenticationStateProvider.cs`) is responsible for managing the user's authentication state and providing the <xref:Microsoft.AspNetCore.Components.Authorization.AuthenticationState> to the app. The `MauiAuthenticationStateProvider` class uses an <xref:System.Net.Http.HttpClient> to make requests to the server to authenticate the user. For more information, see <xref:blazor/hybrid/security/index?pivots=maui>.
198
151
199
152
The `MauiAuthenticationStateProvider` class uses the `HttpClientHelper` (`MauiBlazorWeb/Services/HttpClientHelper.cs`) to handle calling localhost via the emulators and simulators for testing. For more information on calling local services from emulators and simulators, see [Connect to local web services from Android emulators and iOS simulators (.NET MAUI documentation)](/dotnet/maui/data-cloud/local-web-services).
0 commit comments