src/AspNetCore/Mvc/Mvc/src/JsonProblemDetails/IJsonProblemDetailsBuilderExtensions.cs
/// <summary>
/// Adds the problem details services to <see cref="IJsonProblemDetailsBuilder.Services"/>. 
/// The filters <see cref="ProblemDetailsActionFilter"/> and <see cref="ProblemDetailsExceptionFilter"/>
/// are added to <see cref="MvcOptions.Filters"/> via 
/// <see cref="OptionsServiceCollectionExtensions.Configure{TOptions}(IServiceCollection, Action{TOptions})"/>.
/// This means the order of configuring <see cref="MvcOptions"/> matters.
/// </summary>
Adds the problem details services to .
The filters  and
are added to  via
.
This means the order of configuring  matters.
Adds the problem details services to . The filters and are added to via . This means the order of configuring matters .
public static IJsonProblemDetailsBuilder AddJsonProblemDetails(this IJsonProblemDetailsBuilder builder, Action<ProblemDetailsOptions>? configureOptions = null)
        {
            var services = builder.Services ?? throw new ArgumentException();
            if (configureOptions != null) {
                services.Configure(configureOptions);
            }
            services.Configure<MvcOptions>(options => {
                options.Filters.Add<ProblemDetailsActionFilter>();
                options.Filters.Add<ProblemDetailsExceptionFilter>();
            });
            services.AddSingleton<ProblemDetailsMiddlewareContextProvider>();
            services.AddScoped<ProblemDetailsMiddlewareContext>();
            services.AddSingleton<ProblemDetailsMapperProvider>();
            services.AddSingleton<ProblemDetailsResultProvider>();
            services.AddSingleton<IActionResultExecutor<ProblemDetailsResult>, ProblemDetailsResultExecutor>();
            return builder;
        }
public static IJsonProblemDetailsBuilder AddJsonProblemDetails ( this IJsonProblemDetailsBuilder builder , Action < ProblemDetailsOptions > ? configureOptions = null ) { var services = builder . Services ?? throw new ArgumentException ( ) ; if ( configureOptions != null ) { services . Configure ( configureOptions ) ; } services . Configure < MvcOptions > ( options => { options . Filters . Add < ProblemDetailsActionFilter > ( ) ; options . Filters . Add < ProblemDetailsExceptionFilter > ( ) ; } ) ; services . AddSingleton < ProblemDetailsMiddlewareContextProvider > ( ) ; services . AddScoped < ProblemDetailsMiddlewareContext > ( ) ; services . AddSingleton < ProblemDetailsMapperProvider > ( ) ; services . AddSingleton < ProblemDetailsResultProvider > ( ) ; services . AddSingleton < IActionResultExecutor < ProblemDetailsResult > , ProblemDetailsResultExecutor > ( ) ; return builder ; }
Adds the problem details services to .
Adds the problem details services to .
IJsonProblemDetailsBuilder
this
configureOptions
Action<ProblemDetailsOptions>?