Loading...
-}
-else
-{
- @Body
-}
-
-@code {
- [CascadingParameter]
- private HttpContext? HttpContext { get; set; }
-
- protected override void OnParametersSet()
- {
- if (HttpContext is null)
- {
- // If this code runs, we're currently rendering in interactive mode, so there is no HttpContext.
- // The identity pages need to set cookies, so they require an HttpContext. To achieve this we
- // must transition back from interactive mode to a server-rendered page.
- NavigationManager.Refresh(forceReload: true);
- }
- }
-}
diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Shared/ManageLayout.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Shared/ManageLayout.razor
index 6ab82b4b..38c4cee1 100644
--- a/src/mudblazor/MudBlazor.Template/Components/Account/Shared/ManageLayout.razor
+++ b/src/mudblazor/MudBlazor.Template/Components/Account/Shared/ManageLayout.razor
@@ -1,5 +1,9 @@
@inherits LayoutComponentBase
-@layout AccountLayout
+@*#if (UseWebAssembly && InteractiveAtRoot)
+@layout MudBlazor.Template.Client.Layout.MainLayout
+##else
+@layout MudBlazor.Template.Components.Layout.MainLayout
+##endif*@
+
##endif*@
diff --git a/src/mudblazor/MudBlazor.Template/Components/Layout/NavMenu.razor b/src/mudblazor/MudBlazor.Template/Components/Layout/NavMenu.razor
index 4a29e319..d67071bb 100644
--- a/src/mudblazor/MudBlazor.Template/Components/Layout/NavMenu.razor
+++ b/src/mudblazor/MudBlazor.Template/Components/Layout/NavMenu.razor
@@ -8,8 +8,10 @@
Home
@*#if (UseServer || UseWebAssembly)
Counter
-
Weather
##endif*@
+
+
Weather
+
@*#if (IndividualLocalAuth)
Auth Required
@@ -53,6 +55,5 @@
NavigationManager.LocationChanged -= OnLocationChanged;
}
}
-
##endif*@
diff --git a/src/mudblazor/MudBlazor.Template/Components/Pages/Home.razor b/src/mudblazor/MudBlazor.Template/Components/Pages/Home.razor
index 2ba687d7..ecd96d1a 100644
--- a/src/mudblazor/MudBlazor.Template/Components/Pages/Home.razor
+++ b/src/mudblazor/MudBlazor.Template/Components/Pages/Home.razor
@@ -3,7 +3,7 @@
Home
Hello, world!
-Welcome to your new app, powered by MudBlazor and the .NET 8 Template!
+Welcome to your new app, powered by MudBlazor and the .NET 9 Template!
You can find documentation and examples on our website here:
@@ -35,11 +35,12 @@
-What's New in Blazor with the Release of .NET 8
+What's New in Blazor with the Release of .NET 9
+
Prerendering
- If you're exploring the features of .NET 8 Blazor,
you might be pleasantly surprised to learn that each page is prerendered on the server,
regardless of the selected render mode.
+ If you're exploring the features of .NET 9 Blazor,
you might be pleasantly surprised to learn that each page is prerendered on the server,
regardless of the selected render mode.
This means that you'll need to inject all necessary services on the server,
even when opting for the wasm (WebAssembly) render mode.
This prerendering functionality is crucial to ensuring that WebAssembly mode feels fast and responsive,
especially when it comes to initial page load times.
For more information on how to detect prerendering and leverage the RenderContext, you can refer to the following link:
@@ -55,4 +56,4 @@
More details
-
\ No newline at end of file
+
diff --git a/src/mudblazor/MudBlazor.Template/MudBlazor.Template.csproj b/src/mudblazor/MudBlazor.Template/MudBlazor.Template.csproj
index 6bdcc57a..b57f03cb 100644
--- a/src/mudblazor/MudBlazor.Template/MudBlazor.Template.csproj
+++ b/src/mudblazor/MudBlazor.Template/MudBlazor.Template.csproj
@@ -1,7 +1,7 @@
-
+
- net8.0
+ net9.0
enable
enable
aspnet-MudBlazor.Template-53bc9b9d-9d6a-45d4-8429-2a2761773502
@@ -25,15 +25,15 @@
-
-
-
-
-
-
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/src/mudblazor/MudBlazor.Template/Program.Main.cs b/src/mudblazor/MudBlazor.Template/Program.Main.cs
index 6886cdd2..d495cd81 100644
--- a/src/mudblazor/MudBlazor.Template/Program.Main.cs
+++ b/src/mudblazor/MudBlazor.Template/Program.Main.cs
@@ -1,7 +1,6 @@
#if (IndividualLocalAuth)
+#if (UseServer)
using Microsoft.AspNetCore.Components.Authorization;
-#if (!UseServer && !UseWebAssembly)
-using Microsoft.AspNetCore.Components.Server;
#endif
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
@@ -28,16 +27,23 @@ public static void Main(string[] args)
builder.Services.AddMudServices();
// Add services to the container.
-#if (!UseServer && !UseWebAssembly)
+ #if (!UseServer && !UseWebAssembly)
builder.Services.AddRazorComponents();
#else
builder.Services.AddRazorComponents()
- #if (UseServer && UseWebAssembly)
+ #if (UseServer && UseWebAssembly && IndividualLocalAuth)
+ .AddInteractiveServerComponents()
+ .AddInteractiveWebAssemblyComponents()
+ .AddAuthenticationStateSerialization();
+ #elif (UseServer && UseWebAssembly)
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
- #elif(UseServer)
+ #elif (UseServer)
.AddInteractiveServerComponents();
- #elif(UseWebAssembly)
+ #elif (UseWebAssembly && IndividualLocalAuth)
+ .AddInteractiveWebAssemblyComponents()
+ .AddAuthenticationStateSerialization();
+ #elif (UseWebAssembly)
.AddInteractiveWebAssemblyComponents();
#endif
#endif
@@ -46,25 +52,19 @@ public static void Main(string[] args)
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped();
builder.Services.AddScoped();
- #if (UseServer && UseWebAssembly)
- builder.Services.AddScoped();
- #elif (UseServer)
+ #if (UseServer)
builder.Services.AddScoped();
- #elif (UseWebAssembly)
- builder.Services.AddScoped();
- #else
- builder.Services.AddScoped();
#endif
- #if (!UseServer)
- builder.Services.AddAuthorization();
- #endif
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
+ #if (!UseServer)
+ builder.Services.AddAuthorization();
+ #endif
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext(options =>
@@ -112,9 +112,9 @@ public static void Main(string[] args)
app.UseHttpsRedirection();
#endif
- app.UseStaticFiles();
app.UseAntiforgery();
+ app.MapStaticAssets();
#if (UseServer && UseWebAssembly)
app.MapRazorComponents()
.AddInteractiveServerRenderMode()
diff --git a/src/mudblazor/MudBlazor.Template/Program.cs b/src/mudblazor/MudBlazor.Template/Program.cs
index 298da549..bcd86487 100644
--- a/src/mudblazor/MudBlazor.Template/Program.cs
+++ b/src/mudblazor/MudBlazor.Template/Program.cs
@@ -1,7 +1,6 @@
#if (IndividualLocalAuth)
+#if (UseServer)
using Microsoft.AspNetCore.Components.Authorization;
-#if (!UseServer && !UseWebAssembly)
-using Microsoft.AspNetCore.Components.Server;
#endif
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
@@ -26,11 +25,18 @@
builder.Services.AddRazorComponents();
#else
builder.Services.AddRazorComponents()
- #if (UseServer && UseWebAssembly)
+ #if (UseServer && UseWebAssembly && IndividualLocalAuth)
+ .AddInteractiveServerComponents()
+ .AddInteractiveWebAssemblyComponents()
+ .AddAuthenticationStateSerialization();
+ #elif (UseServer && UseWebAssembly)
.AddInteractiveServerComponents()
.AddInteractiveWebAssemblyComponents();
#elif (UseServer)
.AddInteractiveServerComponents();
+ #elif (UseWebAssembly && IndividualLocalAuth)
+ .AddInteractiveWebAssemblyComponents()
+ .AddAuthenticationStateSerialization();
#elif (UseWebAssembly)
.AddInteractiveWebAssemblyComponents();
#endif
@@ -40,25 +46,19 @@
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddScoped();
builder.Services.AddScoped();
-#if (UseServer && UseWebAssembly)
-builder.Services.AddScoped();
-#elif (UseServer)
+#if (UseServer)
builder.Services.AddScoped();
-#elif (UseWebAssembly)
-builder.Services.AddScoped();
-#else
-builder.Services.AddScoped();
#endif
-#if (!UseServer)
-builder.Services.AddAuthorization();
-#endif
builder.Services.AddAuthentication(options =>
{
options.DefaultScheme = IdentityConstants.ApplicationScheme;
options.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies();
+#if (!UseServer)
+builder.Services.AddAuthorization();
+#endif
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection") ?? throw new InvalidOperationException("Connection string 'DefaultConnection' not found.");
builder.Services.AddDbContext(options =>
@@ -106,9 +106,10 @@
app.UseHttpsRedirection();
#endif
-app.UseStaticFiles();
+
app.UseAntiforgery();
+app.MapStaticAssets();
#if (UseServer && UseWebAssembly)
app.MapRazorComponents()
.AddInteractiveServerRenderMode()
diff --git a/src/mudblazor/MudBlazor.Template/Properties/launchSettings.json b/src/mudblazor/MudBlazor.Template/Properties/launchSettings.json
index 8963735e..0d554caa 100644
--- a/src/mudblazor/MudBlazor.Template/Properties/launchSettings.json
+++ b/src/mudblazor/MudBlazor.Template/Properties/launchSettings.json
@@ -1,17 +1,5 @@
{
- "$schema": "http://json.schemastore.org/launchsettings.json",
- "iisSettings": {
- "windowsAuthentication": false,
- "anonymousAuthentication": true,
- "iisExpress": {
- "applicationUrl": "http://localhost:8080",
- //#if (HasHttpsProfile)
- "sslPort": 44300
- //#else
- "sslPort": 0
- //#endif
- }
- },
+ "$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
//#if (HasHttpProfile)
"http": {
@@ -25,7 +13,11 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
+ //#if (HasHttpsProfile)
},
+ //#else
+ }
+ //#endif
//#endif
//#if (HasHttpsProfile)
"https": {
@@ -39,17 +31,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
- },
- //#endif
- "IIS Express": {
- "commandName": "IISExpress",
- "launchBrowser": true,
- //#if (UseWebAssembly)
- "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
- //#endif
- "environmentVariables": {
- "ASPNETCORE_ENVIRONMENT": "Development"
- }
}
+ //#endif
}
}