DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI 2024.0.11.10119

There is a newer version of this package available.
See the version list below for details.
dotnet add package DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI --version 2024.0.11.10119                
NuGet\Install-Package DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI -Version 2024.0.11.10119                
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="DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI" Version="2024.0.11.10119" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI --version 2024.0.11.10119                
#r "nuget: DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI, 2024.0.11.10119"                
#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 DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI as a Cake Addin
#addin nuget:?package=DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI&version=2024.0.11.10119

// Install DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI as a Cake Tool
#tool nuget:?package=DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI&version=2024.0.11.10119                

UI for ASP.NET Core Problem Result Extension

© 2024 DotNet Brightener

Introduction

This is an extensions for ASP.Net Core applications that use the ProblemResult package. This package provides a UI for viewing information about a specific error / exception that can be thrown by the application.

Check out the ProblemResult package for more details on how to implement self-documented error objects.

Installation

You can install the package from NuGet:


dotnet add package DotNetBrightener.AspNet.Extensions.SelfDocumentedProblemResult.UI

Enable UI for viewing errors information

1. Enable generate XML documentation file in your projects / solutions.

Add the following code to the section <PropertyGroup> in your your .csproj file:

<GenerateDocumentationFile>true</GenerateDocumentationFile>

If you have multiple projects in your solution, you'll need to add the above code to all of the projects. Another way is to add that to the Directory.Build.props file in the root of your solution.

2. Configure the ASP.Net project to use the UI package.

Add the following code to your Startup.cs (if you use Startup.cs) or Program.cs (by default) file:


app.MapErrorDocsTrackerUI(options =>
{
    options.UiPath = "/errors-info-ui"; // this is where you can access the UI from your application
    options.ApplicationName = "Test Error"; // this is the name of your application
});

How this work?

When your application is configured to use UI package, the application will collect the error classes that are derived from IProblemResult. The error object when returned from the application, will now have type properties that leads to the information page of the error.

{
  "type": "https://localhost:7290/errors-info-ui#/WebAppCommonShared.Demo.Controllers.UserNotFoundError",
  "title": "User Not Found Error",
  "status": 404,
  "detail": "The error is thrown because the requested resource of type User could not be found",
  "instance": "/api/ExceptionTest/exception2/123",
  "data": {
    "userId": 123
  }
}

If developer / user opens the Url found in type property, they'll be able to see the information about the error. With the provided information, the developer can identify the issue and fix the issue easier. For the user, they can use this to seek support from developer.

Example

Given the error object defined as below:



/// <summary>
///     The error represents the requested object of type `User` could not be found
/// </summary>
/// <remarks>
///     The error is thrown because the requested resource of type `User` could not be found
/// </remarks>
public class UserNotFoundError : BaseProblemDetailsError
{
    public UserNotFoundError()
        : base(HttpStatusCode.NotFound)
    {

    }

    public UserNotFoundError(long userId)
        : this()
    {
        Data.Add("userId", userId);
    }
}

visiting the URL in type property will see an error page like following:

User Not Found Error

Description

The error represents the requested object of type User could not be found

Reason

The error is thrown because the requested resource of type User could not be found

Response HTTP Status Code

The request that encounters this error shall be responded with HTTP Status Code 404.

Additionally, refer to RFC 9110 Document Specification for Status Code 404.

Response Body

Below is the sample response body of the request that encounters this error. Depends on the error, there can be additional properties that help you identify the issue.

{
  "type": "https://localhost:7290/errors#WebAppCommonShared.Demo.Controllers.UserNotFoundError",
  "title": "User Not Found Error",
  "status": 404,
  "detail": "The error is thrown because the requested resource of type User could not be> >found",
  "instance": "{usually is URL of the request}"
}

The Description of the page is pulled from XML Document <summary> tag, and the Reason is pulled from <remarks> tag. The Response HTTP Status Code is the status code that the error object is associated with. The Response Body is the sample response body that the error object will be returned.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2024.0.14.6-rc-243031001 80 10/29/2024
2024.0.14.6-rc-243030701 56 10/29/2024
2024.0.14.6-rc-242840501 62 10/10/2024
2024.0.14.6-rc-242820305 63 10/8/2024
2024.0.14.6-rc-242771401 157 10/3/2024
2024.0.14.6-rc-242770501 70 10/3/2024
2024.0.14.6-rc-242770201 86 10/3/2024
2024.0.14.6-rc-242761801 74 10/2/2024
2024.0.14.6-rc-242761601 82 10/2/2024
2024.0.14.6-rc-242761501 72 10/2/2024
2024.0.14.6-rc-242761401 71 10/2/2024
2024.0.14.6-rc-242760701 86 10/2/2024
2024.0.14.6-rc-242751002 73 10/1/2024
2024.0.14.6-rc-242750901 88 10/1/2024
2024.0.14.6-rc-242750502 75 10/1/2024
2024.0.14.6-rc-242750201 63 10/1/2024
2024.0.14.6-rc-242741501 61 9/30/2024
2024.0.14.6-rc-242730701 93 9/29/2024
2024.0.14.6-preview-2730501 56 9/29/2024
2024.0.14.6-preview-2701501 109 9/26/2024
2024.0.14.6-preview-2620901 120 9/18/2024
2024.0.14.6-preview-2570701 91 9/13/2024
2024.0.14.6-preview-2510703 130 9/7/2024
2024.0.14.6-preview-2480501 89 9/4/2024
2024.0.14.6-preview-2430401 119 8/30/2024
2024.0.14.6-preview-242730701 57 9/29/2024
2024.0.14.6-preview-2421703 78 8/29/2024
2024.0.14.6-preview-2421701 74 8/29/2024
2024.0.14.6-preview-2420901 74 8/29/2024
2024.0.14.6-preview-2390101 108 8/26/2024
2024.0.14.6-preview-2381603 116 8/25/2024
2024.0.14.6-preview-2341601 118 8/21/2024
2024.0.14.6-preview-2321602 101 8/20/2024
2024.0.14.6-preview-2190801 120 8/6/2024
2024.0.14.6-preview-2041501 89 7/22/2024
2024.0.14.6-preview-1920603 140 7/10/2024
2024.0.14.6-preview-1920301 89 7/10/2024
2024.0.14.6-preview-1911302 96 7/9/2024
2024.0.14.6-preview-1901001 101 7/8/2024
2024.0.14.6-preview-1900901 79 7/8/2024
2024.0.14.6-preview-1900801 87 7/8/2024
2024.0.14.6-preview-1860304 86 7/4/2024
2024.0.14.5 116 7/1/2024
2024.0.14.5-preview-1811601 88 6/29/2024
2024.0.14.5-preview-1810501 102 6/29/2024
2024.0.14.5-preview-180132 84 6/28/2024
2024.0.14.5-preview-180131 89 6/28/2024
2024.0.14.5-preview-180121 81 6/28/2024
2024.0.14.4 104 6/27/2024
2024.0.14.4-preview-8 86 6/27/2024
2024.0.14.4-preview-7 68 6/27/2024
2024.0.14.3 92 6/21/2024
2024.0.14.1 94 6/6/2024
2024.0.14.1-preview 66 6/6/2024
2024.0.14-preview-1 83 6/6/2024
2024.0.13.8-preview 87 6/6/2024
2024.0.13.2-preview-247 78 6/6/2024
2024.0.13.1-preview-0146 65 6/6/2024
2024.0.13-preview-1 80 6/6/2024
2024.0.12.15803-preview-03 82 6/6/2024
2024.0.12.15608 96 6/4/2024
2024.0.12.15515 142 6/3/2024
2024.0.12.15220 85 5/31/2024
2024.0.12.15220-alpha31-240... 72 5/31/2024
2024.0.12.14911 115 5/28/2024
2024.0.12.14910-alpha28-240... 75 5/28/2024
2024.0.12.14823 104 5/27/2024
2024.0.12.14522-alpha7-2405... 97 5/24/2024
2024.0.12.14514-alpha6-2405... 98 5/24/2024
2024.0.12.14511 112 5/24/2024
2024.0.12.14314 138 5/22/2024
2024.0.12.14114 127 5/20/2024
2024.0.12.12815 148 5/7/2024
2024.0.12.12814 113 5/7/2024
2024.0.12.12721 137 5/6/2024
2024.0.12.12702 124 5/5/2024
2024.0.12.12622 138 5/5/2024
2024.0.12.12514 109 5/4/2024
2024.0.12.12512 120 5/4/2024
2024.0.12.12510 119 5/4/2024
2024.0.12.12420 95 5/3/2024
2024.0.12.12319 72 5/2/2024
2024.0.12.12319-rc-2405021801 61 5/2/2024
2024.0.12.12318 67 5/2/2024
2024.0.12.12215 105 5/1/2024
2024.0.12.12011 100 4/29/2024
2024.0.12.11720 114 4/26/2024
2024.0.12.11719 104 4/26/2024
2024.0.12.11621 111 4/25/2024
2024.0.12.11523 107 4/24/2024
2024.0.12.11522 107 4/24/2024
2024.0.12.11417 120 4/23/2024
2024.0.12.11400 119 4/22/2024
2024.0.12.11316 119 4/22/2024
2024.0.11.10220 116 4/11/2024
2024.0.11.10120 96 4/10/2024
2024.0.11.10119 99 4/10/2024
2024.0.11.10115 104 4/10/2024
2024.0.11.9914 139 4/8/2024
2024.0.11.9901 104 4/7/2024
2024.0.11.9823 116 4/7/2024
2024.0.11.9401 111 4/2/2024
2024.0.11.9301 104 4/1/2024
2024.0.11.9206 113 3/31/2024
2024.0.11.9205 111 3/31/2024