Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Middleware/Diagnostics/src/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePages
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePages(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, System.Action<Microsoft.AspNetCore.Builder.IApplicationBuilder!>! configuration) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePages(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, System.Func<Microsoft.AspNetCore.Diagnostics.StatusCodeContext!, System.Threading.Tasks.Task!>! handler) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePagesWithRedirects(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, string! locationFormat) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePagesWithReExecute(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, string! pathFormat, string? queryFormat = null) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePagesWithReExecute(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, string! pathFormat, string! queryFormat) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.WelcomePageExtensions.UseWelcomePage(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.WelcomePageExtensions.UseWelcomePage(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, Microsoft.AspNetCore.Builder.WelcomePageOptions! options) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
static Microsoft.AspNetCore.Builder.WelcomePageExtensions.UseWelcomePage(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, Microsoft.AspNetCore.Http.PathString path) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
Expand Down
6 changes: 3 additions & 3 deletions src/Middleware/Diagnostics/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#nullable enable
Microsoft.AspNetCore.Builder.StatusCodePagesOptions.CreateScopeForErrors.get -> bool
Microsoft.AspNetCore.Builder.StatusCodePagesOptions.CreateScopeForErrors.set -> void
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePagesWithReExecute(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, string! pathFormat, bool createScopeForErrors, string? queryFormat = null) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
Microsoft.AspNetCore.Builder.StatusCodePagesOptions.CreateScopeForStatusCodePages.get -> bool
Microsoft.AspNetCore.Builder.StatusCodePagesOptions.CreateScopeForStatusCodePages.set -> void
static Microsoft.AspNetCore.Builder.StatusCodePagesExtensions.UseStatusCodePagesWithReExecute(this Microsoft.AspNetCore.Builder.IApplicationBuilder! app, string! pathFormat, string? queryFormat = null, bool createScopeForStatusCodePages = false) -> Microsoft.AspNetCore.Builder.IApplicationBuilder!
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public static IApplicationBuilder UseStatusCodePages(this IApplicationBuilder ap
return app.UseStatusCodePages(context => tangent(context.HttpContext));
}

// 1.0 BACKCOMPAT OVERLOAD -- DO NOT TOUCH
/// <summary>
/// Adds a StatusCodePages middleware to the pipeline. Specifies that the response body should be generated by
/// re-executing the request pipeline using an alternate path. This path may contain a '{0}' placeholder of the status code.
Expand All @@ -144,7 +145,7 @@ public static IApplicationBuilder UseStatusCodePages(this IApplicationBuilder ap
public static IApplicationBuilder UseStatusCodePagesWithReExecute(
this IApplicationBuilder app,
string pathFormat,
string? queryFormat = null)
string queryFormat)
{
ArgumentNullException.ThrowIfNull(app);

Expand All @@ -168,15 +169,15 @@ public static IApplicationBuilder UseStatusCodePagesWithReExecute(
/// </summary>
/// <param name="app"></param>
/// <param name="pathFormat"></param>
/// <param name="createScopeForErrors">Whether or not to create a new <see cref="IServiceProvider"/> scope.</param>
/// <param name="queryFormat"></param>
/// <param name="createScopeForStatusCodePages">Whether or not to create a new <see cref="IServiceProvider"/> scope.</param>
/// <returns></returns>
[SuppressMessage("ApiDesign", "RS0026:Do not add multiple overloads with optional parameters", Justification = "Required to maintain compatibility")]
public static IApplicationBuilder UseStatusCodePagesWithReExecute(
this IApplicationBuilder app,
string pathFormat,
bool createScopeForErrors,
string? queryFormat = null)
string? queryFormat = null,
bool createScopeForStatusCodePages = false)
{
ArgumentNullException.ThrowIfNull(app);

Expand All @@ -190,7 +191,7 @@ public static IApplicationBuilder UseStatusCodePagesWithReExecute(
Options.Create(new StatusCodePagesOptions()
{
HandleAsync = CreateHandler(pathFormat, queryFormat, newNext),
CreateScopeForErrors = createScopeForErrors,
CreateScopeForStatusCodePages = createScopeForStatusCodePages,
PathFormat = pathFormat
})).Invoke;
});
Expand All @@ -199,7 +200,7 @@ public static IApplicationBuilder UseStatusCodePagesWithReExecute(
var options = new StatusCodePagesOptions
{
HandleAsync = CreateHandler(pathFormat, queryFormat),
CreateScopeForErrors = createScopeForErrors,
CreateScopeForStatusCodePages = createScopeForStatusCodePages,
PathFormat = pathFormat
};
var wrappedOptions = new OptionsWrapper<StatusCodePagesOptions>(options);
Expand All @@ -222,8 +223,8 @@ private static Func<StatusCodeContext, Task> CreateHandler(string pathFormat, st
var originalQueryString = context.HttpContext.Request.QueryString;

var routeValuesFeature = context.HttpContext.Features.Get<IRouteValuesFeature>();
var oldScope = context.Options.CreateScopeForErrors ? context.HttpContext.RequestServices : null;
await using AsyncServiceScope? scope = context.Options.CreateScopeForErrors
var oldScope = context.Options.CreateScopeForStatusCodePages ? context.HttpContext.RequestServices : null;
await using AsyncServiceScope? scope = context.Options.CreateScopeForStatusCodePages
? context.HttpContext.RequestServices.GetRequiredService<IServiceScopeFactory>().CreateAsyncScope()
: null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private static string BuildResponseBody(int httpStatusCode)
/// replace it on <see cref="HttpContext.RequestServices"/> when re-executing the request.
/// </summary>
/// <remarks>The default value is <see langword="false"/>.</remarks>
public bool CreateScopeForErrors { get; set; }
public bool CreateScopeForStatusCodePages { get; set; }

internal string? PathFormat { get; set; }
}
Loading