MadEyeMatt.AspNetCore.ProblemDetails 8.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package MadEyeMatt.AspNetCore.ProblemDetails --version 8.0.0                
NuGet\Install-Package MadEyeMatt.AspNetCore.ProblemDetails -Version 8.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MadEyeMatt.AspNetCore.ProblemDetails" Version="8.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MadEyeMatt.AspNetCore.ProblemDetails --version 8.0.0                
#r "nuget: MadEyeMatt.AspNetCore.ProblemDetails, 8.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MadEyeMatt.AspNetCore.ProblemDetails as a Cake Addin
#addin nuget:?package=MadEyeMatt.AspNetCore.ProblemDetails&version=8.0.0

// Install MadEyeMatt.AspNetCore.ProblemDetails as a Cake Tool
#tool nuget:?package=MadEyeMatt.AspNetCore.ProblemDetails&version=8.0.0                

AspNetCore.ProblemDetails

A middleware to create RFC 7807 problem details for APIs.

Usage

To configute the mandatory services for the problem details middleware just execute AddProblemDetails on the IMvcBuilder instance in your startup code.

WebApplicationBuilder builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services
	.AddControllers()
	.AddProblemDetails(options =>
	{
		// Only include exception details in a development environment. This is the default
		// behavior and is included to demo purposes.
		options.IncludeExceptionDetails = (context, exception) => builder.Environment.IsDevelopment();

		// Use the status code 501 for this type of exception.
		options.MapStatusCode<NotImplementedException>(HttpStatusCode.NotImplemented);

		// Use the status code 501 for this type of exception.
		options.MapStatusCode<InvalidOperationException>(HttpStatusCode.InternalServerError);

		// Add a fallback for all other exceptions with the status code 500.
		options.MapStatusCode<Exception>(HttpStatusCode.InternalServerError);
	});

After you've built your web application instance add the middlware to the pipeline by calling UseProblemDetails.

WebApplication app = builder.Build();

// Configure the HTTP request pipeline.			
app.UseCors();
app.UseProblemDetails();
app.UseHttpsRedirection();
app.UseAuthorization();
app.MapControllers();
app.Run();
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on MadEyeMatt.AspNetCore.ProblemDetails:

Package Downloads
Fluxera.Extensions.Hosting.Modules.AspNetCore.HttpApi

A module that enables HTTP APIs for ASP.NET Core.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
9.0.0 93 11/14/2024
8.0.6 96 11/1/2024
8.0.5 99 7/9/2024
8.0.4 196 5/23/2024
8.0.3 425 4/18/2024
8.0.2 245 3/19/2024
8.0.1 702 11/24/2023
8.0.0 205 11/16/2023
7.2.0 606 3/22/2023
7.1.0 541 1/18/2023
7.0.0 718 11/20/2022
6.2.0 653 10/12/2022
6.1.1 1,804 6/7/2022
6.1.0 420 6/4/2022
6.0.1 440 5/10/2022
6.0.0 432 5/7/2022