Skip to content

Commit aee53a9

Browse files
committed
Per page interactivity test.
1 parent 8744e8b commit aee53a9

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

src/Components/test/E2ETest/ServerRenderingTests/StatusCodePagesTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public class StatusCodePagesTest(BrowserFixture browserFixture, BasicTestAppServ
2121
{
2222

2323
[Fact]
24-
public async Task StatusCodePagesWithReexecution()
24+
public void StatusCodePagesWithReexecution()
2525
{
26-
Navigate($"{ServerPathBase}/set-not-found");
26+
Navigate($"{ServerPathBase}/reexecution/set-not-found");
2727

2828
Browser.Equal("Re-executed page", () => Browser.Title);
2929
var infoText = Browser.FindElement(By.Id("test-info")).Text;

src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7676
app.Map("/reexecution", reexecutionApp =>
7777
{
7878
reexecutionApp.UseStatusCodePagesWithReExecute("/not-found-reexecute", true);
79+
80+
reexecutionApp.UseRouting();
81+
reexecutionApp.UseAntiforgery();
82+
reexecutionApp.UseEndpoints(endpoints =>
83+
{
84+
endpoints.MapRazorComponents<TRootComponent>();
85+
});
7986
});
8087

8188
ConfigureSubdirPipeline(app, env);

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/Index.razor

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/"
2+
@page "/reexecution"
23

34
<PageTitle>Home</PageTitle>
45

src/Components/test/testassets/Components.TestServer/RazorComponents/Pages/ReexecutedPage.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<PageTitle>Re-executed page</PageTitle>
44

55
<h3 id="test-info">Welcome On Page Re-executed After Not Found Event</h3>
6-
<p>This page is shown when UseStatusCodePagesWithReExecute is set and another page sensitive 404</p>
6+
<p>This page is shown when UseStatusCodePagesWithReExecute is set and another page sets 404</p>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ public static IApplicationBuilder UseStatusCodePagesWithReExecute(
199199
HandleAsync = CreateHandler(pathFormat, queryFormat),
200200
CreateScopeForErrors = createScopeForErrors
201201
};
202-
return app.UseMiddleware<StatusCodePagesMiddleware>(options);
202+
var wrappedOptions = new OptionsWrapper<StatusCodePagesOptions>(options);
203+
return app.UseMiddleware<StatusCodePagesMiddleware>(wrappedOptions);
203204
}
204205

205206
private static Func<StatusCodeContext, Task> CreateHandler(string pathFormat, string? queryFormat, RequestDelegate? next = null)
206207
{
207208
var handler = async (StatusCodeContext context) =>
208209
{
209-
// context.Options.CreateScopeForErrors
210210
var originalStatusCode = context.HttpContext.Response.StatusCode;
211211

212212
var newPath = new PathString(
@@ -221,7 +221,7 @@ private static Func<StatusCodeContext, Task> CreateHandler(string pathFormat, st
221221
var routeValuesFeature = context.HttpContext.Features.Get<IRouteValuesFeature>();
222222
var oldScope = context.Options.CreateScopeForErrors ? context.HttpContext.RequestServices : null;
223223
await using AsyncServiceScope? scope = context.Options.CreateScopeForErrors
224-
? context.HttpContext.RequestServices.GetRequiredService<IServiceScopeFactory>().CreateAsyncScope() // or .GetRequiredService<IServiceScopeFactory>().CreateAsyncScope()
224+
? context.HttpContext.RequestServices.GetRequiredService<IServiceScopeFactory>().CreateAsyncScope()
225225
: null;
226226

227227
// Store the original paths so the app can check it.

0 commit comments

Comments
 (0)