Table of Contents

ApplicationBuilderExtensions Class

Definition

Extension methods for the IApplicationBuilder interface.

public static class ApplicationBuilderExtensions
Inheritance
object
ApplicationBuilderExtensions

Examples

The following example demonstrates how to add diagnostics middleware to the ASP.NET Core pipeline using the ApplicationBuilderExtensions class.

using Cuemon.Extensions.AspNetCore.Diagnostics;
using Microsoft.AspNetCore.Builder;

namespace MyApp.Examples;

public class ApplicationBuilderExtensionsExample
{
    public void Configure(IApplicationBuilder app)
    {
        // Add Server-Timing header middleware
        app.UseServerTiming();

        // Add fault descriptor exception handler (catches exceptions and returns structured error responses)
        app.UseFaultDescriptorExceptionHandler();

}
}

Methods

Name Description
UseFaultDescriptorExceptionHandler(IApplicationBuilder)

Adds a middleware to the pipeline that will catch exceptions, log them, and re-execute the request in an alternate pipeline. The request will not be re-executed if the response has already started.

UseServerTiming(IApplicationBuilder)

Adds a Server-Timing HTTP header to the IApplicationBuilder request execution pipeline.