// Set up application services public void ConfigureServices(IServiceCollection services) { var pageRouteTransformerConvention = new PageRouteTransformerConvention(new SlugifyParameterTransformer()); services .AddMvc() .AddRazorPagesOptions(options => { options.Conventions.AddPageRoute("/PageRouteTransformer/PageWithConfiguredRoute", "/PageRouteTransformer/NewConventionRoute/{id?}"); options.Conventions.AddFolderRouteModelConvention("/PageRouteTransformer", model => { pageRouteTransformerConvention.Apply(model); }); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddScoped <TestResponseGenerator>(); services.AddSingleton <IActionContextAccessor, ActionContextAccessor>(); // EndpointRoutingController is not compatible with old routing // Remove its action to avoid errors var actionDescriptorProvider = new RemoveControllerActionDescriptorProvider( new ControllerToRemove { ControllerType = typeof(EndpointRoutingController), Actions = null, // remove all }, new ControllerToRemove { ControllerType = typeof(PageRouteController), Actions = new[] { nameof(PageRouteController.AttributeRoute) } }); services.TryAddEnumerable(ServiceDescriptor.Singleton <IActionDescriptorProvider>(actionDescriptorProvider)); }
// Set up application services public void ConfigureServices(IServiceCollection services) { services .AddMvc() .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddScoped <TestResponseGenerator>(); services.AddSingleton <IActionContextAccessor, ActionContextAccessor>(); // EndpointRoutingController is not compatible with old routing // Remove its action to avoid errors var actionDescriptorProvider = new RemoveControllerActionDescriptorProvider(typeof(EndpointRoutingController)); services.TryAddEnumerable(ServiceDescriptor.Singleton <IActionDescriptorProvider>(actionDescriptorProvider)); }
protected override void ConfigureRoutingServices(IServiceCollection services) { // EndpointRoutingController is not compatible with old routing // Remove its action to avoid errors var actionDescriptorProvider = new RemoveControllerActionDescriptorProvider( new ControllerToRemove { ControllerType = typeof(EndpointRoutingController), Actions = null, // remove all }, new ControllerToRemove { ControllerType = typeof(PageRouteController), Actions = new[] { nameof(PageRouteController.AttributeRoute) } }); services.TryAddEnumerable(ServiceDescriptor.Singleton <IActionDescriptorProvider>(actionDescriptorProvider)); }