Skip to content

EnabledByConvention Class

Application model convention that removes controllers and actions from the application model if their required OIDC endpoint is disabled in configuration.

C#
public class EnabledByConvention : Microsoft.AspNetCore.Mvc.ApplicationModels.IApplicationModelConvention

Inheritance System.Object → EnabledByConvention

Implements Microsoft.AspNetCore.Mvc.ApplicationModels.IApplicationModelConvention

Remarks

This convention checks for the EnabledByAttribute on controllers and actions, removing them from the application model if the specified endpoint is not enabled in EnabledEndpoints. This prevents controllers and actions from being registered at all, rather than returning 404 at runtime.

Constructors

EnabledByConvention(IOptions<OidcOptions>) Constructor

Application model convention that removes controllers and actions from the application model if their required OIDC endpoint is disabled in configuration.

C#
public EnabledByConvention(Microsoft.Extensions.Options.IOptions<Abblix.Oidc.Server.Common.Configuration.OidcOptions> options);

Parameters

options Microsoft.Extensions.Options.IOptions<OidcOptions>

Remarks

This convention checks for the EnabledByAttribute on controllers and actions, removing them from the application model if the specified endpoint is not enabled in EnabledEndpoints. This prevents controllers and actions from being registered at all, rather than returning 404 at runtime.

Methods

EnabledByConvention.Apply(ApplicationModel) Method

Walks the MVC application model and removes any controller or action whose EnabledByAttribute targets an endpoint flag that is not set in EnabledEndpoints. Removed entries are not registered as routes, so requests to them produce a routing 404 (no handler) rather than a runtime filter rejection.

C#
public void Apply(Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModel application);

Parameters

application Microsoft.AspNetCore.Mvc.ApplicationModels.ApplicationModel

Implements Apply(ApplicationModel)