Hi,@David Thielen,
all your razor components were rendered on _Host.cshtml by default
the document related
-
_Host.cshtml
: The root page of the app implemented as a Razor Page: - When any page of the app is initially requested, this page is rendered and returned in the response.
- The Host page specifies where the root
App
component (App.razor
) is rendered.
And app.MapFallbackToPage("/_Host");
is required to map different paths to _Host.cshtml
Then ,you could check the source codes here
public static PageActionEndpointConventionBuilder MapRazorPages(this IEndpointRouteBuilder endpoints)
{
ArgumentNullException.ThrowIfNull(endpoints);
EnsureRazorPagesServices(endpoints);
return GetOrCreateDataSource(endpoints).DefaultBuilder;
}
public static IEndpointConventionBuilder MapFallbackToPage(this IEndpointRouteBuilder endpoints, string page)
{
ArgumentNullException.ThrowIfNull(endpoints);
ArgumentNullException.ThrowIfNull(page);
PageConventionCollection.EnsureValidPageName(page, nameof(page));
EnsureRazorPagesServices(endpoints);
// Called for side-effect to make sure that the data source is registered.
var pageDataSource = GetOrCreateDataSource(endpoints);
pageDataSource.CreateInertEndpoints = true;
RegisterInCache(endpoints.ServiceProvider, pageDataSource);
// Maps a fallback endpoint with an empty delegate. This is OK because
// we don't expect the delegate to run.
var builder = endpoints.MapFallback(context => Task.CompletedTask);
builder.Add(b =>
{
// MVC registers a policy that looks for this metadata.
b.Metadata.Add(CreateDynamicPageMetadata(page, area: null));
b.Metadata.Add(new PageEndpointDataSourceIdMetadata(pageDataSource.DataSourceId));
});
return builder;
}
The two extension methods both call EnsureRazorPagesServices(endpoints);
to handle razor page endpoints.
So you could visit razor page endpoints in default Blazor Server project even if app.MapRazorPages()
is not called
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Ruikai Feng