Skip to content

Commit 765e192

Browse files
mikekistlerCopilot
andauthored
Clarify StatusCodePages ProblemDetails docs (#66172)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent c15ad94 commit 765e192

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesExtensions.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public static class StatusCodePagesExtensions
2020
/// <summary>
2121
/// Adds a StatusCodePages middleware with the given options that checks for responses with status codes
2222
/// between 400 and 599 that do not have a body.
23+
/// If <see cref="StatusCodePagesOptions.HandleAsync"/> uses its default value, it attempts to generate a
24+
/// <see cref="Microsoft.AspNetCore.Mvc.ProblemDetails"/> response using <see cref="IProblemDetailsService"/>
25+
/// and falls back to a plain text response that includes the status code.
2326
/// </summary>
2427
/// <param name="app"></param>
2528
/// <param name="options"></param>
@@ -33,8 +36,11 @@ public static IApplicationBuilder UseStatusCodePages(this IApplicationBuilder ap
3336
}
3437

3538
/// <summary>
36-
/// Adds a StatusCodePages middleware with a default response handler that checks for responses with status codes
37-
/// between 400 and 599 that do not have a body.
39+
/// Adds a <see cref="StatusCodePagesMiddleware"/> with the default response handler.
40+
/// The middleware checks for responses with status codes between 400 and 599 that do not have a body and,
41+
/// when an <see cref="IProblemDetailsService"/> is available, attempts to generate a
42+
/// <see cref="Microsoft.AspNetCore.Mvc.ProblemDetails"/> response. If the service is unavailable or cannot write the response,
43+
/// it generates a plain text response that includes the status code.
3844
/// </summary>
3945
/// <param name="app"></param>
4046
/// <returns></returns>

src/Middleware/Diagnostics/src/StatusCodePage/StatusCodePagesOptions.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ namespace Microsoft.AspNetCore.Builder;
1515
public class StatusCodePagesOptions
1616
{
1717
/// <summary>
18-
/// Creates a default <see cref="StatusCodePagesOptions"/> which produces a plaintext response
19-
/// containing the status code and the reason phrase.
18+
/// Creates a default <see cref="StatusCodePagesOptions"/> whose handler attempts to generate a
19+
/// <see cref="Microsoft.AspNetCore.Mvc.ProblemDetails"/> response using <see cref="IProblemDetailsService"/>, and falls back
20+
/// to a plaintext response containing the status code and reason phrase when that service is unavailable
21+
/// or cannot write a response.
2022
/// </summary>
2123
public StatusCodePagesOptions()
2224
{
@@ -52,7 +54,10 @@ private static string BuildResponseBody(int httpStatusCode)
5254
}
5355

5456
/// <summary>
55-
/// The handler that generates the response body for the given <see cref="StatusCodeContext"/>. By default this produces a plain text response that includes the status code.
57+
/// The handler that generates the response body for the given <see cref="StatusCodeContext"/>.
58+
/// By default this attempts to generate a <see cref="Microsoft.AspNetCore.Mvc.ProblemDetails"/> response
59+
/// using <see cref="IProblemDetailsService"/> and falls back to a plain text response that includes the
60+
/// status code.
5661
/// </summary>
5762
public Func<StatusCodeContext, Task> HandleAsync { get; set; }
5863

0 commit comments

Comments
 (0)