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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public void ConfigureServices(IServiceCollection services)
o.IgnoredResourceExtensions = new[] { "jpg", "gif", "png", "css", "js", "ico", "swf", "woff" };
o.Logging = LoggerMode.On;
o.LogWithHostname = false;
o.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound };
o.AddProvider<NullNotFoundHandlerProvider>();
});

Expand Down Expand Up @@ -151,6 +152,8 @@ If the `bufferSize` is set to `0`, the `threshold` value will be ignored, and ev

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

**ActiveStatusCodes**: A integerlist with the status codes that NotFoundHandler will be active on. (Ex. ```options.ActiveStatusCodes = new int[] { StatusCodes.Status404NotFound, StatusCodes.Status410Gone };```)

### Specifying ignored resources

**IgnoredResourceExtensions**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<PackageId>Geta.NotFoundHandler.Admin</PackageId>
<Title>Admin UI for NotFound Handler for ASP.NET Core and EPiServer</Title>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PackageId>Geta.NotFoundHandler.Optimizely.Commerce</PackageId>
<Title>NotFound handler Admin UI integration Optimizely Commerce</Title>
<Authors>Geta Digital</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<PackageId>Geta.NotFoundHandler.Optimizely</PackageId>
<Title>NotFound handler Admin UI integration Optimizely</Title>
Expand Down
4 changes: 2 additions & 2 deletions src/Geta.NotFoundHandler/Core/RequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public virtual void Handle(HttpContext context)
return;
}

if (context.Response.StatusCode != 404)
if (_configuration.ActiveStatusCodes.Any() && !_configuration.ActiveStatusCodes.Contains(context.Response.StatusCode))
{
LogDebug("Not a 404 response.", context);
LogDebug("Not a accepted statuscode.", context);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Geta.NotFoundHandler/Geta.NotFoundHandler.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<PackageId>Geta.NotFoundHandler</PackageId>
<Title>NotFound Handler for ASP.NET Core</Title>
<Authors>Geta Digital</Authors>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Geta.NotFoundHandler.Core;
using Geta.NotFoundHandler.Core.Suggestions;
using Geta.NotFoundHandler.Core.Redirects;
using Microsoft.AspNetCore.Http;

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

public string[] IgnoredResourceExtensions { get; set; } =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
Loading