Skip to content
Merged
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 @@ -175,11 +175,10 @@ await _renderer.InitializeStandardComponentServicesAsync(
private async Task<RequestValidationState> ValidateRequestAsync(HttpContext context, IAntiforgery? antiforgery)
{
var processPost = HttpMethods.IsPost(context.Request.Method) &&
// Disable POST functionality during exception handling and reexecution.
// Disable POST functionality during exception handling.
// The exception handler middleware will not update the request method, and we don't
// want to run the form handling logic against the error page.
context.Features.Get<IExceptionHandlerFeature>() == null &&
context.Features.Get<IStatusCodePagesFeature>() == null;
context.Features.Get<IExceptionHandlerFeature>() == null;

if (processPost)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ public void CanDispatchToTheDefaultForm(bool suppressEnhancedNavigation)
DispatchToFormCore(dispatchToForm);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void CanDispatchToTheDefaultFormWithReExecutionMiddleware(bool suppressEnhancedNavigation)
{
var dispatchToForm = new DispatchToForm(this)
{
Url = "reexecution/forms/default-form",
FormCssSelector = "form",
SuppressEnhancedNavigation = suppressEnhancedNavigation,
};
DispatchToFormCore(dispatchToForm);
}

[Fact]
public void PlainFormIsNotEnhancedByDefault()
{
Expand Down Expand Up @@ -891,6 +905,21 @@ public async Task CanModifyTheHttpResponseDuringEventHandling()
Assert.Equal("ModifyHttpContext", cookie.Value);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void FormNoAntiforgeryReturnBadRequestWithReExecutionMiddleware(bool suppressEnhancedNavigation)
{
var dispatchToForm = new DispatchToForm(this)
{
Url = "reexecution/forms/no-antiforgery",
FormCssSelector = "form",
ShouldCauseBadRequest = true,
SuppressEnhancedNavigation = suppressEnhancedNavigation,
};
DispatchToFormCore(dispatchToForm);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down Expand Up @@ -973,6 +1002,21 @@ public void FormNoHandlerReturnBadRequest(bool suppressEnhancedNavigation)
DispatchToFormCore(dispatchToForm);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void FormNoHandlerReturnBadRequestWithReExecutionMiddleware(bool suppressEnhancedNavigation)
{
var dispatchToForm = new DispatchToForm(this)
{
Url = "reexecution/forms/no-handler",
FormCssSelector = "form",
ShouldCauseBadRequest = true,
SuppressEnhancedNavigation = suppressEnhancedNavigation,
};
DispatchToFormCore(dispatchToForm);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/forms/default-form"
@page "/reexecution/forms/default-form"
@using Microsoft.AspNetCore.Components.Forms

<h2>Default form</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/forms/no-antiforgery"
@page "/reexecution/forms/no-antiforgery"
@using Microsoft.AspNetCore.Components.Forms

<h2>Default form</h2>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@page "/forms/no-handler"
@page "/reexecution/forms/no-handler"
@using Microsoft.AspNetCore.Components.Forms

<h2>Form with no handler</h2>
Expand Down
Loading