diff --git a/aspnetcore/mvc/razor-pages/razor-pages-convention-features.md b/aspnetcore/mvc/razor-pages/razor-pages-convention-features.md index 87906ee3a6..f0734a653a 100644 --- a/aspnetcore/mvc/razor-pages/razor-pages-convention-features.md +++ b/aspnetcore/mvc/razor-pages/razor-pages-convention-features.md @@ -36,6 +36,25 @@ Learn how to use page [route and app model provider convention](xref:mvc/control | [Default page app model provider](#replace-the-default-page-app-model-provider) | Replace the default page model provider to change the conventions for handler names. | ::: moniker-end +Razor Pages conventions are added and configured using the [AddRazorPagesOptions](/dotnet/api/microsoft.extensions.dependencyinjection.mvcrazorpagesmvcbuilderextensions.addrazorpagesoptions) extension method to [AddMvc](/dotnet/api/microsoft.extensions.dependencyinjection.mvcservicecollectionextensions.addmvc) on the service collection in the `Startup` class. The following convention examples are explained later in this topic: + +```csharp +public void ConfigureServices(IServiceCollection services) +{ + services.AddMvc() + .AddRazorPagesOptions(options => + { + options.Conventions.Add( ... ); + options.Conventions.AddFolderRouteModelConvention("/OtherPages", model => { ... }); + options.Conventions.AddPageRouteModelConvention("/About", model => { ... }); + options.Conventions.AddPageRoute("/Contact", "TheContactPage/{text?}"); + options.Conventions.AddFolderApplicationModelConvention("/OtherPages", model => { ... }); + options.Conventions.AddPageApplicationModelConvention("/About", model => { ... }); + options.Conventions.ConfigureFilter(model => { ... }); + options.Conventions.ConfigureFilter( ... ); + }); +} +``` ## Model conventions