Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal partial class EndpointHtmlRenderer

protected override IComponent ResolveComponentForRenderMode([DynamicallyAccessedMembers(Component)] Type componentType, int? parentComponentId, IComponentActivator componentActivator, IComponentRenderMode renderMode)
{
if (_isHandlingErrors || _isReExecuted)
if (_isHandlingErrors)
{
// Ignore the render mode boundary in error scenarios.
return componentActivator.CreateInstance(componentType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,24 @@ public void BrowserNavigationToNotExistingPathReExecutesTo404(string renderMode)
Assert404ReExecuted();
}

[Fact]
public void BrowserNavigationToNotExistingPathReExecutesTo404_Interactive()
{
// non-existing path has to have re-execution middleware set up
// so it has to have "interactive-reexecution" prefix. Otherwise middleware mapping
// will not be activated, see configuration in Startup
Navigate($"{ServerPathBase}/interactive-reexecution/not-existing-page");
Assert404ReExecuted();
AssertReExecutedPageIsInteractive();
}

private void AssertReExecutedPageIsInteractive()
{
Browser.Equal("Current count: 0", () => Browser.FindElement(By.CssSelector("[role='status']")).Text);
Browser.Click(By.Id("increment-button"));
Browser.Equal("Current count: 1", () => Browser.FindElement(By.CssSelector("[role='status']")).Text);
}

private void Assert404ReExecuted() =>
Browser.Equal("Welcome On Page Re-executed After Not Found Event", () => Browser.Exists(By.Id("test-info")).Text);
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
reexecutionApp.UseAntiforgery();
ConfigureEndpoints(reexecutionApp, env);
});
app.Map("/interactive-reexecution", reexecutionApp =>
{
reexecutionApp.UseStatusCodePagesWithReExecute("/not-found-reexecute-interactive", createScopeForStatusCodePages: true);
reexecutionApp.UseRouting();
reexecutionApp.UseAntiforgery();
ConfigureEndpoints(reexecutionApp, env);
});

ConfigureSubdirPipeline(app, env);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<PageTitle>Re-executed page</PageTitle>

<h3 id="test-info">Welcome On Page Re-executed After Not Found Event</h3>
<p>This page is shown when UseStatusCodePagesWithReExecute is set and another page sets 404</p>
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@page "/not-found-reexecute"

<PageTitle>Re-executed page</PageTitle>

<h3 id="test-info">Welcome On Page Re-executed After Not Found Event</h3>
<p>This page is shown when UseStatusCodePagesWithReExecute is set and another page sets 404</p>
<ReExecutedComponent />
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@page "/not-found-reexecute-interactive"
@rendermode RenderMode.InteractiveServer

<ReExecutedComponent />

<p role="status">Current count: @currentCount</p>

<button id="increment-button" class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
private int currentCount = 0;

private void IncrementCount()
{
currentCount++;
}
}
Loading