-
-
-
-
\ No newline at end of file
+@inject IHostEnvironment Env
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @if (Env.IsDevelopment())
+ {
+
+ An unhandled exception has occurred. See browser dev tools for details.
+
+ }
+ else
+ {
+
+ An error has occurred. This app may no longer respond until reloaded.
+
+ }
+ Reload
+ 🗙
+
-Welcome to your new app.
+@if (User != null && User.Identity.IsAuthenticated)
+{
+
Welcome, @User.Identity.Name!
+}
+else
+{
+
Welcome to our app!
+
You are not authenticated.
+
Please log in to continue.
+}
-
\ No newline at end of file
+
+
+@code {
+ private ClaimsPrincipal User { get; set; }
+
+ protected override async Task OnInitializedAsync()
+ {
+ var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
+ User = authState.User;
+ }
+}
\ No newline at end of file
diff --git a/samples/BlazorServer/Pages/_Host.cshtml b/samples/BlazorServer/Pages/_Host.cshtml
deleted file mode 100644
index ceddf59..0000000
--- a/samples/BlazorServer/Pages/_Host.cshtml
+++ /dev/null
@@ -1,8 +0,0 @@
-@page "/"
-@namespace BlazorServer.Pages
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
-@{
- Layout = "_Layout";
-}
-
-
\ No newline at end of file
diff --git a/samples/BlazorServer/Pages/_Layout.cshtml b/samples/BlazorServer/Pages/_Layout.cshtml
deleted file mode 100644
index 815cd75..0000000
--- a/samples/BlazorServer/Pages/_Layout.cshtml
+++ /dev/null
@@ -1,32 +0,0 @@
-@using Microsoft.AspNetCore.Components.Web
-@namespace BlazorServer.Pages
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
-
-
-
-
-
-
-
-
-
-
-
-
-
-@RenderBody()
-
-
-
- An error has occurred. This application may no longer respond until reloaded.
-
-
- An unhandled exception has occurred. See browser dev tools for details.
-
- Reload
- 🗙
-
-
-
-
-
\ No newline at end of file
diff --git a/samples/BlazorServer/Routes.razor b/samples/BlazorServer/Routes.razor
new file mode 100644
index 0000000..c519d1b
--- /dev/null
+++ b/samples/BlazorServer/Routes.razor
@@ -0,0 +1,25 @@
+
+
+
+
+
+ @if (context.User.Identity?.IsAuthenticated != true)
+ {
+
+ }
+ else
+ {
+
You are not authorized to access this resource.
+ }
+
+
+
+
+
+ Not found
+
+
Sorry, there's nothing at this address.
+
+
+
+
\ No newline at end of file
diff --git a/samples/BlazorServer/_Imports.razor b/samples/BlazorServer/_Imports.razor
index 84b0efa..74a8047 100644
--- a/samples/BlazorServer/_Imports.razor
+++ b/samples/BlazorServer/_Imports.razor
@@ -7,4 +7,5 @@
@using Microsoft.AspNetCore.Components.Web.Virtualization
@using Microsoft.JSInterop
@using BlazorServer
-@using BlazorServer.Shared
\ No newline at end of file
+@using BlazorServer.Shared
+@using static Microsoft.AspNetCore.Components.Web.RenderMode
\ No newline at end of file