Skip to content

Commit b65535a

Browse files
authored
Merge pull request #155 from wezz/feature/support-410
Add support for redirects on 410 responses
2 parents 7883e13 + c1e6a6e commit b65535a

File tree

9 files changed

+13
-8
lines changed

9 files changed

+13
-8
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void ConfigureServices(IServiceCollection services)
6969
o.IgnoredResourceExtensions = new[] { "jpg", "gif", "png", "css", "js", "ico", "swf", "woff" };
7070
o.Logging = LoggerMode.On;
7171
o.LogWithHostname = false;
72+
o.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound };
7273
o.AddProvider<NullNotFoundHandlerProvider>();
7374
});
7475
@@ -151,6 +152,8 @@ If the `bufferSize` is set to `0`, the `threshold` value will be ignored, and ev
151152

152153
**LogWithHostname**: Set to `true` to include hostname in the log. Useful in a multisite environment with several hostnames/domains. Default is `false`
153154

155+
**ActiveStatusCodes**: A integerlist with the status codes that NotFoundHandler will be active on. (Ex. ```options.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound, StatusCodes.Status410Gone };```)
156+
154157
### Specifying ignored resources
155158

156159
**IgnoredResourceExtensions**

src/Geta.NotFoundHandler.Admin/Geta.NotFoundHandler.Admin.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
66
<PackageId>Geta.NotFoundHandler.Admin</PackageId>
77
<Title>Admin UI for NotFound Handler for ASP.NET Core and EPiServer</Title>

src/Geta.NotFoundHandler.Optimizely.Commerce/Geta.NotFoundHandler.Optimizely.Commerce.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<PackageId>Geta.NotFoundHandler.Optimizely.Commerce</PackageId>
66
<Title>NotFound handler Admin UI integration Optimizely Commerce</Title>
77
<Authors>Geta Digital</Authors>

src/Geta.NotFoundHandler.Optimizely/Geta.NotFoundHandler.Optimizely.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk.Razor">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
66
<PackageId>Geta.NotFoundHandler.Optimizely</PackageId>
77
<Title>NotFound handler Admin UI integration Optimizely</Title>

src/Geta.NotFoundHandler/Core/RequestHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public virtual void Handle(HttpContext context)
4444
return;
4545
}
4646

47-
if (context.Response.StatusCode != 404)
47+
if (_configuration.ActiveStatusCodes.Any() && !_configuration.ActiveStatusCodes.Contains(context.Response.StatusCode))
4848
{
49-
LogDebug("Not a 404 response.", context);
49+
LogDebug("Not a accepted statuscode.", context);
5050
return;
5151
}
5252

src/Geta.NotFoundHandler/Geta.NotFoundHandler.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<PackageId>Geta.NotFoundHandler</PackageId>
66
<Title>NotFound Handler for ASP.NET Core</Title>
77
<Authors>Geta Digital</Authors>

src/Geta.NotFoundHandler/Infrastructure/Configuration/NotFoundHandlerOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Geta.NotFoundHandler.Core;
77
using Geta.NotFoundHandler.Core.Suggestions;
88
using Geta.NotFoundHandler.Core.Redirects;
9+
using Microsoft.AspNetCore.Http;
910

1011
namespace Geta.NotFoundHandler.Infrastructure.Configuration
1112
{
@@ -20,6 +21,7 @@ public class NotFoundHandlerOptions
2021
public bool UseInternalScheduler { get; set; }
2122
public string InternalSchedulerCronInterval { get; set; } = "0 0 * * *";
2223
public FileNotFoundMode HandlerMode { get; set; } = FileNotFoundMode.On;
24+
public int[] ActiveStatusCodes { get; set; } = new int[] { StatusCodes.Status404NotFound };
2325
public TimeSpan RegexTimeout { get; set; } = TimeSpan.FromMilliseconds(100);
2426

2527
public string[] IgnoredResourceExtensions { get; set; } =

tests/Geta.NotFoundHandler.Optimizely.Tests/Geta.NotFoundHandler.Optimizely.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

tests/Geta.NotFoundHandler.Tests/Geta.NotFoundHandler.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<IsPackable>false</IsPackable>
66
</PropertyGroup>
77

0 commit comments

Comments
 (0)