In .NET 9 Preview 4, we added a feature to exclude pages from interactive routing using the new [ExcludeFromInteractiveRouting] attribute. This feature simplifies using static pages in a Blazor app that is otherwise setup with global interactivity using an interactive router. This feature should be used with the Blazor Identity scaffolder.
To use the feature, we need to include an _Imports.razor file in the folder with the scaffolded components that includes the @attribute [ExcludeFormInteractiveRouting] directive. This will add metadata to the page's endpoint that can then be used to configure the router appropriately when the app is setup for global interactivity. If the app is using global interactivity, the required changes in App.razor look like this (substituting for InteractiveServer the actual render mode used globally by the app):
In .NET 9 Preview 4, we added a feature to exclude pages from interactive routing using the new
[ExcludeFromInteractiveRouting]
attribute. This feature simplifies using static pages in a Blazor app that is otherwise setup with global interactivity using an interactive router. This feature should be used with the Blazor Identity scaffolder.To use the feature, we need to include an _Imports.razor file in the folder with the scaffolded components that includes the
@attribute [ExcludeFormInteractiveRouting]
directive. This will add metadata to the page's endpoint that can then be used to configure the router appropriately when the app is setup for global interactivity. If the app is using global interactivity, the required changes in App.razor look like this (substituting forInteractiveServer
the actual render mode used globally by the app):We've already updated the Blazor Web App template in .NET 9 to use the
[ExcludeFromInteractiveRouting]
feature when the template uses global interactivity and ASP.NET Core Identity for auth. You can see the related changes that should be emulated in the Blazor Identity scaffolder in this PR: https://github.com/dotnet/aspnetcore/pull/55157/files#diff-fd16fee9145b20d81c4c2a48e4daf91fef913bd729d395185595bae2fc1daae2.