Skip to content

Commit d566c4b

Browse files
committed
This is a draft of uneffective UseStatusCodePagesWithReExecute, cc @javiercn.
1 parent b660d19 commit d566c4b

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

src/Components/Endpoints/src/RazorComponentEndpointInvoker.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ private async Task RenderComponentCore(HttpContext context)
3939
{
4040
context.Response.ContentType = RazorComponentResultExecutor.DefaultContentType;
4141
var isErrorHandler = context.Features.Get<IExceptionHandlerFeature>() is not null;
42+
var hasStatusCodePage = context.Features.Get<IStatusCodePagesFeature>() is not null;
4243
if (isErrorHandler)
4344
{
4445
Log.InteractivityDisabledForErrorHandling(_logger);
4546
}
46-
_renderer.InitializeStreamingRenderingFraming(context, isErrorHandler);
47+
_renderer.InitializeStreamingRenderingFraming(context, isErrorHandler, hasStatusCodePage);
4748
EndpointHtmlRenderer.MarkAsAllowingEnhancedNavigation(context);
4849

4950
var endpoint = context.GetEndpoint() ?? throw new InvalidOperationException($"An endpoint must be set on the '{nameof(HttpContext)}'.");

src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Prerendering.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ internal partial class EndpointHtmlRenderer
1818

1919
protected override IComponent ResolveComponentForRenderMode([DynamicallyAccessedMembers(Component)] Type componentType, int? parentComponentId, IComponentActivator componentActivator, IComponentRenderMode renderMode)
2020
{
21-
if (_isHandlingErrors)
21+
if (_isHandlingErrors || _hasStatusCodePage)
2222
{
2323
// Ignore the render mode boundary in error scenarios.
2424
return componentActivator.CreateInstance(componentType);

src/Components/Endpoints/src/Rendering/EndpointHtmlRenderer.Streaming.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ internal partial class EndpointHtmlRenderer
2222
private HashSet<int>? _visitedComponentIdsInCurrentStreamingBatch;
2323
private string? _ssrFramingCommentMarkup;
2424
private bool _isHandlingErrors;
25+
private bool _hasStatusCodePage;
2526

26-
public void InitializeStreamingRenderingFraming(HttpContext httpContext, bool isErrorHandler)
27+
public void InitializeStreamingRenderingFraming(HttpContext httpContext, bool isErrorHandler, bool hasStatusCodePage)
2728
{
2829
_isHandlingErrors = isErrorHandler;
30+
_hasStatusCodePage = hasStatusCodePage;
2931
if (IsProgressivelyEnhancedNavigation(httpContext.Request))
3032
{
3133
var id = Guid.NewGuid().ToString();

src/Components/Endpoints/src/Results/RazorComponentResultExecutor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ private static Task RenderComponentToResponse(
4848
return endpointHtmlRenderer.Dispatcher.InvokeAsync(async () =>
4949
{
5050
var isErrorHandler = httpContext.Features.Get<IExceptionHandlerFeature>() is not null;
51-
endpointHtmlRenderer.InitializeStreamingRenderingFraming(httpContext, isErrorHandler);
51+
var hasStatusCodePage = httpContext.Features.Get<IStatusCodePagesFeature>() is not null;
52+
endpointHtmlRenderer.InitializeStreamingRenderingFraming(httpContext, isErrorHandler, hasStatusCodePage);
5253
EndpointHtmlRenderer.MarkAsAllowingEnhancedNavigation(httpContext);
5354

5455
// We could pool these dictionary instances if we wanted, and possibly even the ParameterView

0 commit comments

Comments
 (0)