diff --git a/.github/workflows/continuous.yml b/.github/workflows/continuous.yml index df1d5b20..b83ba806 100644 --- a/.github/workflows/continuous.yml +++ b/.github/workflows/continuous.yml @@ -30,7 +30,6 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.0.x 9.0.x - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 diff --git a/.github/workflows/mudblazor-ci.yml b/.github/workflows/mudblazor-ci.yml index 83fdfe03..d7445b5b 100644 --- a/.github/workflows/mudblazor-ci.yml +++ b/.github/workflows/mudblazor-ci.yml @@ -1,6 +1,6 @@ name: mudblazor-ci -on: +'on': push: branches: [ dev ] pull_request: @@ -11,11 +11,14 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v4 - - name: Setup dotnet - uses: actions/setup-dotnet@v4 - - name: Install and build all templates - shell: pwsh - run: | - ./InstallAndBuildAllTemplates.ps1 + - name: Checkout repository + uses: actions/checkout@v4 + - name: Setup dotnet + uses: actions/setup-dotnet@v4 + with: + dotnet-version: | + 9.0.x + - name: Install and build all templates + shell: pwsh + run: | + ./InstallAndBuildAllTemplates.ps1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd473cd5..c01ec11a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,7 +34,6 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: | - 8.0.x 9.0.x - name: 'Cache: .nuke/temp, ~/.nuget/packages' uses: actions/cache@v4 diff --git a/src/MudBlazor.Templates.csproj b/src/MudBlazor.Templates.csproj index d355a396..677e0a91 100644 --- a/src/MudBlazor.Templates.csproj +++ b/src/MudBlazor.Templates.csproj @@ -18,7 +18,7 @@ Template - net8.0 + net9.0 true false content diff --git a/src/mudblazor/.template.config/dotnetcli.host.json b/src/mudblazor/.template.config/dotnetcli.host.json index 897cc417..9c853513 100644 --- a/src/mudblazor/.template.config/dotnetcli.host.json +++ b/src/mudblazor/.template.config/dotnetcli.host.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/dotnetcli.host", + "$schema": "https://json.schemastore.org/dotnetcli.host", "symbolInfo": { "skipRestore": { "longName": "no-restore", diff --git a/src/mudblazor/.template.config/ide.host.json b/src/mudblazor/.template.config/ide.host.json index 5c5a1d00..71b187ae 100644 --- a/src/mudblazor/.template.config/ide.host.json +++ b/src/mudblazor/.template.config/ide.host.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/ide.host", + "$schema": "https://json.schemastore.org/ide.host", "order": 610, "icon": "icon.png", "disableHttpsSymbol": "NoHttps", diff --git a/src/mudblazor/.template.config/localize/templatestrings.cs.json b/src/mudblazor/.template.config/localize/templatestrings.cs.json index 257b3f7b..a934cfaf 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.cs.json +++ b/src/mudblazor/.template.config/localize/templatestrings.cs.json @@ -3,7 +3,7 @@ "name": "Webová aplikace Blazor", "description": "Šablona projektu pro vytvoření webové aplikace Blazor, která podporuje vykreslování na straně serveru i interaktivitu klienta. Tato šablona se dá použít pro webové aplikace s bohatými dynamickými uživatelskými rozhraními (UI).", "symbols/Framework/description": "Cílová architektura pro projekt", - "symbols/Framework/choices/net8.0/description": "Cílový net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "ID, které se má použít pro tajné kódy (používá se s individuálním ověřováním).", "symbols/skipRestore/description": "Pokud se tato možnost zadá, přeskočí automatické obnovení projektu při vytvoření.", "symbols/ExcludeLaunchSettings/description": "Určuje, jestli se má z vygenerované šablony vyloučit soubor launchSettings.json.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.de.json b/src/mudblazor/.template.config/localize/templatestrings.de.json index 63c5d226..4edfb2d9 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.de.json +++ b/src/mudblazor/.template.config/localize/templatestrings.de.json @@ -3,7 +3,7 @@ "name": "Blazor-Web-App", "description": "Eine Projektvorlage zum Erstellen einer Blazor-Web-App, die sowohl serverseitiges Rendering als auch Clientinteraktivität unterstützt. Diese Vorlage kann für Web-Apps mit umfangreichen dynamischen Benutzeroberflächen (UIs) verwendet werden.", "symbols/Framework/description": "Das Zielframework für das Projekt.", - "symbols/Framework/choices/net8.0/description": "Ziel net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "Die für Geheimnisse zu verwendende ID (Verwendung mit individueller Authentifizierung).", "symbols/skipRestore/description": "Wenn angegeben, wird die automatische Wiederherstellung des Projekts beim Erstellen übersprungen.", "symbols/ExcludeLaunchSettings/description": "Ob launchSettings.json aus der generierten Vorlage ausgeschlossen werden soll.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.en.json b/src/mudblazor/.template.config/localize/templatestrings.en.json index a9a6afb8..6d6fb4ad 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.en.json +++ b/src/mudblazor/.template.config/localize/templatestrings.en.json @@ -3,7 +3,7 @@ "name": "Blazor Web App", "description": "A project template for creating a Blazor web app that supports both server-side rendering and client interactivity. This template can be used for web apps with rich dynamic user interfaces (UIs).", "symbols/Framework/description": "The target framework for the project.", - "symbols/Framework/choices/net8.0/description": "Target net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "The ID to use for secrets (use with Individual auth).", "symbols/skipRestore/description": "If specified, skips the automatic restore of the project on create.", "symbols/ExcludeLaunchSettings/description": "Whether to exclude launchSettings.json from the generated template.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.es.json b/src/mudblazor/.template.config/localize/templatestrings.es.json index 6fa1439a..5ee91daa 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.es.json +++ b/src/mudblazor/.template.config/localize/templatestrings.es.json @@ -3,7 +3,7 @@ "name": "Aplicación web Blazor", "description": "Plantilla de proyecto para crear una aplicación web de Blazor que admita tanto la representación del lado del servidor como la interactividad del cliente. Esta plantilla se puede usar para las aplicaciones web con interfaces de usuario dinámicas enriquecidas.", "symbols/Framework/description": "Marco de destino del proyecto.", - "symbols/Framework/choices/net8.0/description": "net8.0 de destino", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "Identificador que se va a usar para los secretos (se usa con la autenticación individual).", "symbols/skipRestore/description": "Si se especifica, se omite la restauración automática del proyecto durante la creación.", "symbols/ExcludeLaunchSettings/description": "Indica si se va a excluir launchSettings.json de la plantilla generada.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.fr.json b/src/mudblazor/.template.config/localize/templatestrings.fr.json index 0c53c3a3..0d253403 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.fr.json +++ b/src/mudblazor/.template.config/localize/templatestrings.fr.json @@ -3,7 +3,7 @@ "name": "Application web Blazor", "description": "Modèle de projet pour la création d’une application web Blazor qui prend en charge le rendu côté serveur et l’interactivité du client. Ce modèle peut être utilisé pour les applications web avec des interfaces utilisateur dynamiques enrichies.", "symbols/Framework/description": "Framework cible du projet.", - "symbols/Framework/choices/net8.0/description": "Cible net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "ID à utiliser pour les secrets (à utiliser avec l’authentification individuelle).", "symbols/skipRestore/description": "S’il est spécifié, ignore la restauration automatique du projet lors de la création.", "symbols/ExcludeLaunchSettings/description": "Indique s’il faut exclure launchSettings.json du modèle généré.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.it.json b/src/mudblazor/.template.config/localize/templatestrings.it.json index 9745c46f..bd544332 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.it.json +++ b/src/mudblazor/.template.config/localize/templatestrings.it.json @@ -3,7 +3,7 @@ "name": "App Web Blazor", "description": "Modello di progetto per la creazione di un'app Web Blazor che supporta sia il rendering lato server sia l'interattività client. Questo modello può essere usato per app Web con interfacce utente dinamiche avanzate.", "symbols/Framework/description": "Il framework di destinazione per il progetto.", - "symbols/Framework/choices/net8.0/description": "Destinazione net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "ID da usare per i segreti (usare con l'autenticazione Individual).", "symbols/skipRestore/description": "Se specificato, ignora il ripristino automatico del progetto durante la creazione.", "symbols/ExcludeLaunchSettings/description": "Indica se escludere launchSettings.json dal modello generato.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.ja.json b/src/mudblazor/.template.config/localize/templatestrings.ja.json index 983a5263..1c23498c 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.ja.json +++ b/src/mudblazor/.template.config/localize/templatestrings.ja.json @@ -3,7 +3,7 @@ "name": "Blazor Web アプリ", "description": "サーバー側のレンダリングとクライアントの対話機能の両方をサポートする Blazor Web アプリを作成するためのプロジェクト テンプレートです。このテンプレートは、リッチな動的ユーザー インターフェイス (UI) を持つ Web アプリに使用できます。", "symbols/Framework/description": "プロジェクトのターゲット フレームワークです。", - "symbols/Framework/choices/net8.0/description": "ターゲット net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "シークレットで使用する ID (IndividualAuth で使用)。", "symbols/skipRestore/description": "指定した場合、作成時にプロジェクトの自動復元がスキップされます。", "symbols/ExcludeLaunchSettings/description": "生成されたテンプレートから launchSettings.json を除外するかどうか。", diff --git a/src/mudblazor/.template.config/localize/templatestrings.ko.json b/src/mudblazor/.template.config/localize/templatestrings.ko.json index 84621a6b..e204607c 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.ko.json +++ b/src/mudblazor/.template.config/localize/templatestrings.ko.json @@ -3,7 +3,7 @@ "name": "Blazor 웹앱", "description": "서버 측 렌더링 및 클라이언트 대화형 작업을 모두 지원하는 Blazor 웹앱을 만들기 위한 프로젝트 템플릿입니다. 이 템플릿은 풍부한 동적 UI(사용자 인터페이스)가 있는 웹앱에 사용할 수 있습니다.", "symbols/Framework/description": "프로젝트에 대한 대상 프레임워크입니다.", - "symbols/Framework/choices/net8.0/description": "대상 net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "비밀에 사용할 ID입니다(개별 인증과 함께 사용).", "symbols/skipRestore/description": "지정된 경우, 프로젝트 생성 시 자동 복원을 건너뜁니다.", "symbols/ExcludeLaunchSettings/description": "생성된 템플릿에서 launchSettings.json을 제외할지 여부입니다.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.pl.json b/src/mudblazor/.template.config/localize/templatestrings.pl.json index 98c0512d..680c85b1 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.pl.json +++ b/src/mudblazor/.template.config/localize/templatestrings.pl.json @@ -3,7 +3,7 @@ "name": "Aplikacja internetowa Blazor", "description": "Szablon projektu służący do tworzenia aplikacji internetowej platformy Blazor, która obsługuje renderowanie po stronie serwera i interakcyjność klienta. Ten szablon może być używany dla aplikacji internetowych z zaawansowanymi dynamicznymi interfejsami użytkownika.", "symbols/Framework/description": "Platforma docelowa dla tego projektu.", - "symbols/Framework/choices/net8.0/description": "Docelowa platforma net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "Identyfikator do użycia dla wpisów tajnych (używany z indywidualnym uwierzytelnianym).", "symbols/skipRestore/description": "Jeśli ta opcja jest określona, pomija automatyczne przywracanie projektu podczas tworzenia.", "symbols/ExcludeLaunchSettings/description": "Określa, czy wykluczyć plik launchSettings.json z wygenerowanego szablonu.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.pt-BR.json b/src/mudblazor/.template.config/localize/templatestrings.pt-BR.json index 5126e768..95709542 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.pt-BR.json +++ b/src/mudblazor/.template.config/localize/templatestrings.pt-BR.json @@ -3,7 +3,7 @@ "name": "Aplicativo Web Blazor", "description": "Um modelo de projeto para criar um aplicativo Web Blazor que dá suporte à renderização do lado do servidor e à interatividade do cliente. Este modelo pode ser usado para aplicativos da Web com interfaces de usuário (UIs) dinâmicas avançadas.", "symbols/Framework/description": "A estrutura de destino do projeto.", - "symbols/Framework/choices/net8.0/description": "net8.0 de destino", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "O ID a ser usado para segredos (usado com autenticação individual).", "symbols/skipRestore/description": "Se especificado, ignora a restauração automática do projeto sendo criado.", "symbols/ExcludeLaunchSettings/description": "Se deve excluir launchSettings.json do modelo gerado.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.ru.json b/src/mudblazor/.template.config/localize/templatestrings.ru.json index 871a1009..2a2f7b50 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.ru.json +++ b/src/mudblazor/.template.config/localize/templatestrings.ru.json @@ -3,7 +3,7 @@ "name": "Веб-приложение Blazor", "description": "Шаблон проекта для создания приложения Blazor, поддерживающего как отрисовку на стороне сервера, так и интерактивные возможности клиента. Этот шаблон можно использовать для веб-приложений с многофункциональными динамическими пользовательскими интерфейсами (UI).", "symbols/Framework/description": "Целевая платформа для проекта.", - "symbols/Framework/choices/net8.0/description": "Целевая net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "Идентификатор, используемый для секретов (применяется с индивидуальной проверкой подлинности).", "symbols/skipRestore/description": "Если установлено, автоматическое восстановление проекта при создании пропускается.", "symbols/ExcludeLaunchSettings/description": "Следует ли исключить launchSettings.json из созданного шаблона.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.tr.json b/src/mudblazor/.template.config/localize/templatestrings.tr.json index 157e8912..aebc293d 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.tr.json +++ b/src/mudblazor/.template.config/localize/templatestrings.tr.json @@ -3,7 +3,7 @@ "name": "Blazor Web Uygulaması", "description": "Hem sunucu tarafı işlemeyi hem de istemci etkileşimini destekleyen bir Blazor web uygulaması oluşturmaya yönelik proje şablonu. Bu şablon, zengin dinamik kullanıcı arabirimlerine (UI) sahip web uygulamaları için kullanılabilir.", "symbols/Framework/description": "Projenin hedef çerçevesi.", - "symbols/Framework/choices/net8.0/description": "Hedef net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "Gizli diziler için kullanılacak kimlik (Bireysel kimlik doğrulamayla kullanın).", "symbols/skipRestore/description": "Belirtilirse, oluşturma sırasında projenin otomatik geri yüklenmesini atlar.", "symbols/ExcludeLaunchSettings/description": "launchSettings.json öğesinin oluşturulan şablondan dışlanıp dışlanmayacağı.", diff --git a/src/mudblazor/.template.config/localize/templatestrings.zh-Hans.json b/src/mudblazor/.template.config/localize/templatestrings.zh-Hans.json index 9c18022e..01048e22 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.zh-Hans.json +++ b/src/mudblazor/.template.config/localize/templatestrings.zh-Hans.json @@ -3,7 +3,7 @@ "name": "Blazor Web 应用", "description": "用于创建支持服务器端呈现和客户端交互的 Blazor Web 应用的项目模板。此模板可用于具有丰富动态用户界面 (UI) 的 Web 应用。", "symbols/Framework/description": "项目的目标框架。", - "symbols/Framework/choices/net8.0/description": "目标 net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "用于机密的 ID (与个人身份验证一起使用)。", "symbols/skipRestore/description": "如果指定,则在创建时跳过项目的自动还原。", "symbols/ExcludeLaunchSettings/description": "是否从生成的模板中排除 launchSettings.json。", diff --git a/src/mudblazor/.template.config/localize/templatestrings.zh-Hant.json b/src/mudblazor/.template.config/localize/templatestrings.zh-Hant.json index eff89b1b..b34e4fd9 100644 --- a/src/mudblazor/.template.config/localize/templatestrings.zh-Hant.json +++ b/src/mudblazor/.template.config/localize/templatestrings.zh-Hant.json @@ -3,7 +3,7 @@ "name": "Blazor Web 應用程式", "description": "用於建立同時支援伺服器端轉譯和用戶端互動的 Blazor Web 應用程式的專案範本。此範本可用於具有豐富動態使用者介面 (UI) 的 Web 應用程式。", "symbols/Framework/description": "專案的目標 Framework。", - "symbols/Framework/choices/net8.0/description": "目標 net8.0", + "symbols/Framework/choices/net9.0/description": "Target net9.0", "symbols/UserSecretsId/description": "用於祕密的識別碼 (搭配個別驗證使用)。", "symbols/skipRestore/description": "若指定,會在建立時跳過專案的自動還原。", "symbols/ExcludeLaunchSettings/description": "是否要從產生的範本排除 launchSettings.json。", diff --git a/src/mudblazor/.template.config/template.json b/src/mudblazor/.template.config/template.json index fccfc427..a104aab1 100644 --- a/src/mudblazor/.template.config/template.json +++ b/src/mudblazor/.template.config/template.json @@ -1,5 +1,5 @@ { - "$schema": "http://json.schemastore.org/template", + "$schema": "https://json.schemastore.org/template", "author": "MudBlazor", "classifications": [ "Web", @@ -18,7 +18,7 @@ "650B3CE7-2E93-4CC4-9F46-466686815EAA", "53bc9b9d-9d6a-45d4-8429-2a2761773502" ], - "identity": "MudBlazorWebApp.CSharp.8.0", + "identity": "MudBlazorWebApp.CSharp.9.0", "thirdPartyNotices": "", "preferNameDirectory": true, "primaryOutputs": [ @@ -52,13 +52,7 @@ "**/wwwroot/bootstrap/**" ], "modifiers": [ - { - "condition": "(!IndividualLocalAuth)", - "exclude": [ - "**/wwwroot/bootstrap/**" - ] - }, - { + { "condition": "(!UseWebAssembly)", "exclude": [ "MudBlazor.Template.Client/**", @@ -73,6 +67,7 @@ "rename": { "MudBlazor.Template/Components/Layout/": "./MudBlazor.Template.Client/Layout/", "MudBlazor.Template/Components/Pages/Home.razor": "./MudBlazor.Template.Client/Pages/Home.razor", + "MudBlazor.Template/Components/Pages/Weather.razor": "./MudBlazor.Template.Client/Pages/Weather.razor", "MudBlazor.Template/Components/Routes.razor": "./MudBlazor.Template.Client/Routes.razor" } }, @@ -94,10 +89,9 @@ } }, { - "condition": "(UseWebAssembly || (!UseWebAssembly && !UseServer))", + "condition": "(!(UseServer && !UseWebAssembly))", "exclude": [ - "MudBlazor.Template/Components/Pages/Counter.razor", - "MudBlazor.Template/Components/Pages/Weather.razor" + "MudBlazor.Template/Components/Pages/Counter.razor" ] }, { @@ -130,7 +124,6 @@ "exclude": [ "MudBlazor.Template/Components/Account/**", "MudBlazor.Template/Data/**", - "MudBlazor.Template.Client/PersistentAuthenticationStateProvider.cs", "MudBlazor.Template.Client/UserInfo.cs", "MudBlazor.Template.Client/Pages/Auth.razor" ] @@ -148,24 +141,12 @@ ] }, { - "condition": "(!(IndividualLocalAuth && UseServer && UseWebAssembly))", - "exclude": [ - "MudBlazor.Template/Components/Account/PersistingRevalidatingAuthenticationStateProvider.cs" - ] - }, - { - "condition": "(!(IndividualLocalAuth && UseServer && !UseWebAssembly))", + "condition": "(!(IndividualLocalAuth && UseServer))", "exclude": [ "MudBlazor.Template/Components/Account/IdentityRevalidatingAuthenticationStateProvider.cs" ] }, - { - "condition": "(!(IndividualLocalAuth && !UseServer && UseWebAssembly))", - "exclude": [ - "MudBlazor.Template/Components/Account/PersistingServerAuthenticationStateProvider.cs" - ] - }, - { + { "condition": "(IndividualLocalAuth && UseLocalDB && UseWebAssembly)", "rename": { "MudBlazor.Template/Data/SqlServer/": "MudBlazor.Template/Data/Migrations/" @@ -217,12 +198,12 @@ "datatype": "choice", "choices": [ { - "choice": "net8.0", - "description": "Target net8.0" + "choice": "net9.0", + "description": "Target net9.0" } ], - "replaces": "net8.0", - "defaultValue": "net8.0" + "replaces": "net9.0", + "defaultValue": "net9.0" }, "HostIdentifier": { "type": "bind", diff --git a/src/mudblazor/MudBlazor.Template.Client/MudBlazor.Template.Client.csproj b/src/mudblazor/MudBlazor.Template.Client/MudBlazor.Template.Client.csproj index 670e7b5b..52a2a2be 100644 --- a/src/mudblazor/MudBlazor.Template.Client/MudBlazor.Template.Client.csproj +++ b/src/mudblazor/MudBlazor.Template.Client/MudBlazor.Template.Client.csproj @@ -1,7 +1,7 @@ - net8.0 + net9.0 enable enable true @@ -11,9 +11,9 @@ - - + + - + \ No newline at end of file diff --git a/src/mudblazor/MudBlazor.Template.Client/Pages/Weather.razor b/src/mudblazor/MudBlazor.Template.Client/Pages/Weather.razor deleted file mode 100644 index 465fd796..00000000 --- a/src/mudblazor/MudBlazor.Template.Client/Pages/Weather.razor +++ /dev/null @@ -1,77 +0,0 @@ -@page "/weather" -@*#if (UseServer && !InteractiveAtRoot) -@rendermode InteractiveAuto -##elseif (!InteractiveAtRoot) -@rendermode InteractiveWebAssembly -##endif*@ - -@*#if (!InteractiveAtRoot) - - - -##endif*@ - -@*#if (!InteractiveAtRoot) --> -@attribute [StreamRendering] -##endif*@ - -Weather - -Weather forecast -This component demonstrates fetching data from the server. - -@if (forecasts == null) -{ - -} -else -{ - - - Date - Temp. (C) - Temp. (F) - Summary - - - @context.Date - @context.TemperatureC - @context.TemperatureF - @context.Summary - - - - - -} - -@code { - private WeatherForecast[]? forecasts; - - protected override async Task OnInitializedAsync() - { -@*#if (InteractiveAtRoot) --> - // Simulate asynchronous loading to demonstrate a loading indicator -##else - // Simulate asynchronous loading to demonstrate streaming rendering -##endif*@ - await Task.Delay(500); - - var startDate = DateOnly.FromDateTime(DateTime.Now); - var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; - forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast - { - Date = startDate.AddDays(index), - TemperatureC = Random.Shared.Next(-20, 55), - Summary = summaries[Random.Shared.Next(summaries.Length)] - }).ToArray(); - } - - private class WeatherForecast - { - public DateOnly Date { get; set; } - public int TemperatureC { get; set; } - public string? Summary { get; set; } - public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); - } -} diff --git a/src/mudblazor/MudBlazor.Template.Client/PersistentAuthenticationStateProvider.cs b/src/mudblazor/MudBlazor.Template.Client/PersistentAuthenticationStateProvider.cs deleted file mode 100644 index 9c8e7318..00000000 --- a/src/mudblazor/MudBlazor.Template.Client/PersistentAuthenticationStateProvider.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Security.Claims; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Authorization; - -namespace MudBlazor.Template.Client; - -// This is a client-side AuthenticationStateProvider that determines the user's authentication state by -// looking for data persisted in the page when it was rendered on the server. This authentication state will -// be fixed for the lifetime of the WebAssembly application. So, if the user needs to log in or out, a full -// page reload is required. -// -// This only provides a user name and email for display purposes. It does not actually include any tokens -// that authenticate to the server when making subsequent requests. That works separately using a -// cookie that will be included on HttpClient requests to the server. -internal class PersistentAuthenticationStateProvider : AuthenticationStateProvider -{ - private static readonly Task defaultUnauthenticatedTask = - Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity()))); - - private readonly Task authenticationStateTask = defaultUnauthenticatedTask; - - public PersistentAuthenticationStateProvider(PersistentComponentState state) - { - if (!state.TryTakeFromJson(nameof(UserInfo), out var userInfo) || userInfo is null) - { - return; - } - - Claim[] claims = [ - new Claim(ClaimTypes.NameIdentifier, userInfo.UserId), - new Claim(ClaimTypes.Name, userInfo.Email), - new Claim(ClaimTypes.Email, userInfo.Email) ]; - - authenticationStateTask = Task.FromResult( - new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(claims, - authenticationType: nameof(PersistentAuthenticationStateProvider))))); - } - - public override Task GetAuthenticationStateAsync() => authenticationStateTask; -} diff --git a/src/mudblazor/MudBlazor.Template.Client/Program.Main.cs b/src/mudblazor/MudBlazor.Template.Client/Program.Main.cs index 2ddab1a5..7dd2b730 100644 --- a/src/mudblazor/MudBlazor.Template.Client/Program.Main.cs +++ b/src/mudblazor/MudBlazor.Template.Client/Program.Main.cs @@ -1,7 +1,3 @@ -#if (IndividualLocalAuth) -using MudBlazor.Template.Client; -using Microsoft.AspNetCore.Components.Authorization; -#endif using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using MudBlazor.Services; @@ -12,16 +8,14 @@ class Program static async Task Main(string[] args) { var builder = WebAssemblyHostBuilder.CreateDefault(args); - - builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddMudServices(); #if (IndividualLocalAuth) builder.Services.AddAuthorizationCore(); builder.Services.AddCascadingAuthenticationState(); - builder.Services.AddSingleton(); -#endif + builder.Services.AddAuthenticationStateDeserialization(); + #endif await builder.Build().RunAsync(); } } diff --git a/src/mudblazor/MudBlazor.Template.Client/Program.cs b/src/mudblazor/MudBlazor.Template.Client/Program.cs index 1824e22b..2a917fae 100644 --- a/src/mudblazor/MudBlazor.Template.Client/Program.cs +++ b/src/mudblazor/MudBlazor.Template.Client/Program.cs @@ -1,19 +1,14 @@ -#if (IndividualLocalAuth) -using MudBlazor.Template.Client; -using Microsoft.AspNetCore.Components.Authorization; -#endif using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using MudBlazor.Services; var builder = WebAssemblyHostBuilder.CreateDefault(args); -builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); builder.Services.AddMudServices(); #if (IndividualLocalAuth) builder.Services.AddAuthorizationCore(); builder.Services.AddCascadingAuthenticationState(); -builder.Services.AddSingleton(); +builder.Services.AddAuthenticationStateDeserialization(); #endif await builder.Build().RunAsync(); diff --git a/src/mudblazor/MudBlazor.Template.Client/UserInfo.cs b/src/mudblazor/MudBlazor.Template.Client/UserInfo.cs deleted file mode 100644 index fe85b65c..00000000 --- a/src/mudblazor/MudBlazor.Template.Client/UserInfo.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace MudBlazor.Template.Client; - -// Add properties to this class and update the server and client AuthenticationStateProviders -// to expose more information about the authenticated user to the client. -public class UserInfo -{ - public required string UserId { get; set; } - public required string Email { get; set; } -} diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/IdentityComponentsEndpointRouteBuilderExtensions.cs b/src/mudblazor/MudBlazor.Template/Components/Account/IdentityComponentsEndpointRouteBuilderExtensions.cs index a5f32bbf..ceb03f24 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/IdentityComponentsEndpointRouteBuilderExtensions.cs +++ b/src/mudblazor/MudBlazor.Template/Components/Account/IdentityComponentsEndpointRouteBuilderExtensions.cs @@ -42,7 +42,7 @@ public static IEndpointConventionBuilder MapAdditionalIdentityEndpoints(this IEn accountGroup.MapPost("/Logout", async ( ClaimsPrincipal user, - SignInManager signInManager, + [FromServices] SignInManager signInManager, [FromForm] string returnUrl) => { await signInManager.SignOutAsync(); diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ExternalLogin.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ExternalLogin.razor index 997b7da8..ee5c55b3 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ExternalLogin.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ExternalLogin.razor @@ -35,8 +35,8 @@
- - + +
@@ -48,7 +48,7 @@ public const string LoginCallbackAction = "LoginCallback"; private string? message; - private ExternalLoginInfo externalLoginInfo = default!; + private ExternalLoginInfo? externalLoginInfo; [CascadingParameter] private HttpContext HttpContext { get; set; } = default!; @@ -65,7 +65,7 @@ [SupplyParameterFromQuery] private string? Action { get; set; } - private string? ProviderDisplayName => externalLoginInfo.ProviderDisplayName; + private string? ProviderDisplayName => externalLoginInfo?.ProviderDisplayName; protected override async Task OnInitializedAsync() { @@ -98,10 +98,15 @@ private async Task OnLoginCallbackAsync() { + if (externalLoginInfo is null) + { + RedirectManager.RedirectToWithStatus("Account/Login", "Error loading external login information.", HttpContext); + } + // Sign in the user with this external login provider if the user already has a login. var result = await SignInManager.ExternalLoginSignInAsync( - externalLoginInfo.LoginProvider, - externalLoginInfo.ProviderKey, + externalLoginInfo!.LoginProvider, + externalLoginInfo!.ProviderKey, isPersistent: false, bypassTwoFactor: true); @@ -127,6 +132,11 @@ private async Task OnValidSubmitAsync() { + if (externalLoginInfo is null) + { + RedirectManager.RedirectToWithStatus("Account/Login", "Error loading external login information during confirmation.", HttpContext); + } + var emailStore = GetEmailStore(); var user = CreateUser(); @@ -164,7 +174,7 @@ message = $"Error: {string.Join(",", result.Errors.Select(error => error.Description))}"; } - private ApplicationUser CreateUser() + private static ApplicationUser CreateUser() { try { diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ForgotPassword.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ForgotPassword.razor index 27ef1192..061c98fc 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ForgotPassword.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ForgotPassword.razor @@ -15,15 +15,15 @@ Forgot your password? Forgot your password? - Enter your email. + - diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/InvalidPasswordReset.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/InvalidPasswordReset.razor index 509578bb..561b651a 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/InvalidPasswordReset.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/InvalidPasswordReset.razor @@ -3,6 +3,6 @@ Invalid password reset

Invalid password reset

-

+

The password reset link is invalid.

diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Lockout.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Lockout.razor index a8d1e0af..017e31d3 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Lockout.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Lockout.razor @@ -4,5 +4,5 @@

Locked out

-

This account has been locked out, please try again later.

+
diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Login.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Login.razor index ec185008..187f3a89 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Login.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Login.razor @@ -26,7 +26,7 @@ + UserAttributes="@(new() { { "autocomplete", "username" }, { "aria-required", "true" } } )" />
- - + +
diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/Email.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/Email.razor index 51165739..2159d22f 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/Email.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/Email.razor @@ -43,7 +43,7 @@ } - + diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/SetPassword.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/SetPassword.razor index ba50d093..0fe59726 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/SetPassword.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Manage/SetPassword.razor @@ -18,18 +18,18 @@ account so you can log in without an external login.

-
+
- - + +
- - + +
diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Register.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Register.razor index 1f7d3c73..a2dcf55d 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Register.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/Register.razor @@ -31,7 +31,7 @@ + UserAttributes="@(new() { { "autocomplete", "username" }, { "aria-required", "true" } } )" /> Please check your email to confirm your account.

+

Please check your email to confirm your account.

} @code { diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResendEmailConfirmation.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResendEmailConfirmation.razor index 86e4ee8b..7aff4072 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResendEmailConfirmation.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResendEmailConfirmation.razor @@ -27,7 +27,7 @@ + UserAttributes="@(new() { { "autocomplete", "username" }, { "aria-required", "true" } } )" /> Resend diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPassword.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPassword.razor index 922a2a69..7cc68a58 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPassword.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPassword.razor @@ -23,18 +23,18 @@
- - + +
- - + +
- - + +
diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPasswordConfirmation.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPasswordConfirmation.razor index ac54ab60..247e96ec 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPasswordConfirmation.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/ResetPasswordConfirmation.razor @@ -2,6 +2,6 @@ Reset password confirmation

Reset password confirmation

-

- Your password has been reset. Please click here to log in. +

+ Your password has been reset. Please click here to log in.

diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/_Imports.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/_Imports.razor index ef2581cd..78eca821 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Pages/_Imports.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Account/Pages/_Imports.razor @@ -1,3 +1,3 @@ @using MudBlazor @using MudBlazor.Template.Components.Account.Shared -@layout AccountLayout +@attribute [ExcludeFromInteractiveRouting] diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/PersistingRevalidatingAuthenticationStateProvider.cs b/src/mudblazor/MudBlazor.Template/Components/Account/PersistingRevalidatingAuthenticationStateProvider.cs deleted file mode 100644 index 5be232d3..00000000 --- a/src/mudblazor/MudBlazor.Template/Components/Account/PersistingRevalidatingAuthenticationStateProvider.cs +++ /dev/null @@ -1,109 +0,0 @@ -using System.Diagnostics; -using System.Security.Claims; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Server; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.Options; -using MudBlazor.Template.Client; -using MudBlazor.Template.Data; - -namespace MudBlazor.Template.Components.Account; - -// This is a server-side AuthenticationStateProvider that revalidates the security stamp for the connected user -// every 30 minutes an interactive circuit is connected. It also uses PersistentComponentState to flow the -// authentication state to the client which is then fixed for the lifetime of the WebAssembly application. -internal sealed class PersistingRevalidatingAuthenticationStateProvider : RevalidatingServerAuthenticationStateProvider -{ - private readonly IServiceScopeFactory scopeFactory; - private readonly PersistentComponentState state; - private readonly IdentityOptions options; - - private readonly PersistingComponentStateSubscription subscription; - - private Task? authenticationStateTask; - - public PersistingRevalidatingAuthenticationStateProvider( - ILoggerFactory loggerFactory, - IServiceScopeFactory serviceScopeFactory, - PersistentComponentState persistentComponentState, - IOptions optionsAccessor) - : base(loggerFactory) - { - scopeFactory = serviceScopeFactory; - state = persistentComponentState; - options = optionsAccessor.Value; - - AuthenticationStateChanged += OnAuthenticationStateChanged; - subscription = state.RegisterOnPersisting(OnPersistingAsync, RenderMode.InteractiveWebAssembly); - } - - protected override TimeSpan RevalidationInterval => TimeSpan.FromMinutes(30); - - protected override async Task ValidateAuthenticationStateAsync( - AuthenticationState authenticationState, CancellationToken cancellationToken) - { - // Get the user manager from a new scope to ensure it fetches fresh data - await using var scope = scopeFactory.CreateAsyncScope(); - var userManager = scope.ServiceProvider.GetRequiredService>(); - return await ValidateSecurityStampAsync(userManager, authenticationState.User); - } - - private async Task ValidateSecurityStampAsync(UserManager userManager, ClaimsPrincipal principal) - { - var user = await userManager.GetUserAsync(principal); - if (user is null) - { - return false; - } - else if (!userManager.SupportsUserSecurityStamp) - { - return true; - } - else - { - var principalStamp = principal.FindFirstValue(options.ClaimsIdentity.SecurityStampClaimType); - var userStamp = await userManager.GetSecurityStampAsync(user); - return principalStamp == userStamp; - } - } - - private void OnAuthenticationStateChanged(Task task) - { - authenticationStateTask = task; - } - - private async Task OnPersistingAsync() - { - if (authenticationStateTask is null) - { - throw new UnreachableException($"Authentication state not set in {nameof(OnPersistingAsync)}()."); - } - - var authenticationState = await authenticationStateTask; - var principal = authenticationState.User; - - if (principal.Identity?.IsAuthenticated == true) - { - var userId = principal.FindFirst(options.ClaimsIdentity.UserIdClaimType)?.Value; - var email = principal.FindFirst(options.ClaimsIdentity.EmailClaimType)?.Value; - - if (userId != null && email != null) - { - state.PersistAsJson(nameof(UserInfo), new UserInfo - { - UserId = userId, - Email = email, - }); - } - } - } - - protected override void Dispose(bool disposing) - { - subscription.Dispose(); - AuthenticationStateChanged -= OnAuthenticationStateChanged; - base.Dispose(disposing); - } -} diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/PersistingServerAuthenticationStateProvider.cs b/src/mudblazor/MudBlazor.Template/Components/Account/PersistingServerAuthenticationStateProvider.cs deleted file mode 100644 index 3c2912cb..00000000 --- a/src/mudblazor/MudBlazor.Template/Components/Account/PersistingServerAuthenticationStateProvider.cs +++ /dev/null @@ -1,70 +0,0 @@ -using System.Diagnostics; -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Server; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Identity; -using Microsoft.Extensions.Options; -using MudBlazor.Template.Client; - -namespace MudBlazor.Template.Components.Account; - -// This is a server-side AuthenticationStateProvider that uses PersistentComponentState to flow the -// authentication state to the client which is then fixed for the lifetime of the WebAssembly application. -internal sealed class PersistingServerAuthenticationStateProvider : ServerAuthenticationStateProvider, IDisposable -{ - private readonly PersistentComponentState state; - private readonly IdentityOptions options; - - private readonly PersistingComponentStateSubscription subscription; - - private Task? authenticationStateTask; - - public PersistingServerAuthenticationStateProvider( - PersistentComponentState persistentComponentState, - IOptions optionsAccessor) - { - state = persistentComponentState; - options = optionsAccessor.Value; - - AuthenticationStateChanged += OnAuthenticationStateChanged; - subscription = state.RegisterOnPersisting(OnPersistingAsync, RenderMode.InteractiveWebAssembly); - } - - private void OnAuthenticationStateChanged(Task task) - { - authenticationStateTask = task; - } - - private async Task OnPersistingAsync() - { - if (authenticationStateTask is null) - { - throw new UnreachableException($"Authentication state not set in {nameof(OnPersistingAsync)}()."); - } - - var authenticationState = await authenticationStateTask; - var principal = authenticationState.User; - - if (principal.Identity?.IsAuthenticated == true) - { - var userId = principal.FindFirst(options.ClaimsIdentity.UserIdClaimType)?.Value; - var email = principal.FindFirst(options.ClaimsIdentity.EmailClaimType)?.Value; - - if (userId != null && email != null) - { - state.PersistAsJson(nameof(UserInfo), new UserInfo - { - UserId = userId, - Email = email, - }); - } - } - } - - public void Dispose() - { - subscription.Dispose(); - AuthenticationStateChanged -= OnAuthenticationStateChanged; - } -} diff --git a/src/mudblazor/MudBlazor.Template/Components/Account/Shared/AccountLayout.razor b/src/mudblazor/MudBlazor.Template/Components/Account/Shared/AccountLayout.razor deleted file mode 100644 index f574ce88..00000000 --- a/src/mudblazor/MudBlazor.Template/Components/Account/Shared/AccountLayout.razor +++ /dev/null @@ -1,32 +0,0 @@ -@inherits LayoutComponentBase -@*#if (UseWebAssembly && InteractiveAtRoot) -@layout MudBlazor.Template.Client.Layout.MainLayout -##else -@layout MudBlazor.Template.Components.Layout.MainLayout -##endif*@ -@inject NavigationManager NavigationManager - -@if (HttpContext is null) -{ -

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*@ Manage your account diff --git a/src/mudblazor/MudBlazor.Template/Components/App.razor b/src/mudblazor/MudBlazor.Template/Components/App.razor index 8602ef92..dca1efc2 100644 --- a/src/mudblazor/MudBlazor.Template/Components/App.razor +++ b/src/mudblazor/MudBlazor.Template/Components/App.razor @@ -6,14 +6,15 @@ - + + @*#if (SampleContent) ##endif*@ @*#if (!InteractiveAtRoot) ##elseif (IndividualLocalAuth) - + ##elseif (UseServer && UseWebAssembly) ##elseif (UseServer) @@ -27,7 +28,7 @@ @*#if (!InteractiveAtRoot) ##elseif (IndividualLocalAuth) - + ##elseif (UseServer && UseWebAssembly) ##elseif (UseServer) @@ -50,9 +51,8 @@ [CascadingParameter] private HttpContext HttpContext { get; set; } = default!; - private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account") - ? null - : InteractiveAuto; + private IComponentRenderMode? PageRenderMode => + HttpContext.AcceptsInteractiveRouting() ? InteractiveAuto : null; } #elseif (UseServer) @@ -60,9 +60,8 @@ [CascadingParameter] private HttpContext HttpContext { get; set; } = default!; - private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account") - ? null - : InteractiveServer; + private IComponentRenderMode? PageRenderMode => + HttpContext.AcceptsInteractiveRouting() ? InteractiveServer : null; } #else @@ -70,8 +69,7 @@ [CascadingParameter] private HttpContext HttpContext { get; set; } = default!; - private IComponentRenderMode? RenderModeForPage => HttpContext.Request.Path.StartsWithSegments("/Account") - ? null - : InteractiveWebAssembly; + private IComponentRenderMode? PageRenderMode => + HttpContext.AcceptsInteractiveRouting() ? InteractiveWebAssembly : null; } #endif*@ diff --git a/src/mudblazor/MudBlazor.Template/Components/Layout/MainLayout.razor b/src/mudblazor/MudBlazor.Template/Components/Layout/MainLayout.razor index 1bf401c2..f2bf60b1 100644 --- a/src/mudblazor/MudBlazor.Template/Components/Layout/MainLayout.razor +++ b/src/mudblazor/MudBlazor.Template/Components/Layout/MainLayout.razor @@ -35,10 +35,10 @@ @*#if (UseServer || UseWebAssembly) --> -
+
An unhandled error has occurred. - Reload - 🗙 + Reload + 🗙
##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 } }