Skip to content

Commit 7a7b72e

Browse files
committed
Merge branch 'bugfix/NotFound' into develop
Previously, the `[ValidateTopic]` attribute returned a custom error message alongside the `NotFound` result. As a result, the `UseStatusCodePages()` middleware failed to intercept the request since it had already written to the response stream. By removing this custom message, we ensure that the `UseStatusCodePages()` middleware can take effect. This includes an integration test to confirm this fix resolves the issue.
2 parents 7cfa5ca + 812cf98 commit 7a7b72e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

OnTopic.AspNetCore.Mvc.IntegrationTests/ServiceCollectionExtensionsTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public async Task MapTopicSitemap_RespondsToRequest() {
9494
/// </summary>
9595
[Theory]
9696
[InlineData("/MissingPage/", HttpStatusCode.NotFound, "400")]
97+
[InlineData("/Web/MissingPage/", HttpStatusCode.NotFound, "400")]
9798
[InlineData("/Web/Container/", HttpStatusCode.Forbidden, "400")]
9899
public async Task UseStatusCodePages_ReturnsExpectedStatusCode(string path, HttpStatusCode statusCode, string expectedContent) {
99100

OnTopic.AspNetCore.Mvc/_filters/ValidateTopicAttribute.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public override void OnActionExecuting(ActionExecutingContext context) {
7575

7676
if (currentTopic is null) {
7777
if (!AllowNull) {
78-
context.Result = controller.NotFound("There is no topic associated with this path.");
78+
context.Result = controller.NotFound();
7979
}
8080
return;
8181
}

0 commit comments

Comments
 (0)