Skip to content

Commit c51fa08

Browse files
authored
Document IPNetwork and ForwardedHeadersOptions.KnownNetworks obsolescence for .NET 10 (#47899)
1 parent 6af3952 commit c51fa08

File tree

3 files changed

+53
-0
lines changed

3 files changed

+53
-0
lines changed

docs/core/compatibility/10.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ If you're migrating an app to .NET 10, the breaking changes listed here might af
2424
| [Exception diagnostics suppressed when TryHandleAsync returns true](aspnet-core/10/exception-handler-diagnostics-suppressed.md) | Behavioral change | Preview 7 |
2525
| [IActionContextAccessor and ActionContextAccessor are obsolete](aspnet-core/10/iactioncontextaccessor-obsolete.md) | Source incompatible/behavioral change | Preview 7 |
2626
| [IncludeOpenAPIAnalyzers property and MVC API analyzers are deprecated](aspnet-core/10/openapi-analyzers-deprecated.md) | Source incompatible | Preview 7 |
27+
| [IPNetwork and ForwardedHeadersOptions.KnownNetworks are obsolete](aspnet-core/10/ipnetwork-knownnetworks-obsolete.md) | Source incompatible | Preview 7 |
2728
| [Microsoft.Extensions.ApiDescription.Client package deprecated](aspnet-core/10/apidescription-client-deprecated.md) | Source incompatible | Preview 7 |
2829
| [Razor run-time compilation is obsolete](aspnet-core/10/razor-runtime-compilation-obsolete.md) | Source incompatible | Preview 7 |
2930

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
---
2+
title: "Breaking change: IPNetwork and ForwardedHeadersOptions.KnownNetworks are obsolete"
3+
description: Learn about the breaking change in ASP.NET Core 10.0 where IPNetwork and ForwardedHeadersOptions.KnownNetworks have been obsoleted in favor of System.Net.IPNetwork and KnownIPNetworks.
4+
ms.date: 08/08/2025
5+
ai-usage: ai-assisted
6+
ms.custom: https://github.com/aspnet/Announcements/issues/523
7+
---
8+
# IPNetwork and ForwardedHeadersOptions.KnownNetworks are obsolete
9+
10+
<xref:Microsoft.AspNetCore.HttpOverrides.IPNetwork?displayProperty=fullName> and <xref:Microsoft.AspNetCore.Builder.ForwardedHeadersOptions.KnownNetworks> have been marked as obsolete in favor of using <xref:System.Net.IPNetwork?displayProperty=fullName> and `KnownIPNetworks`.
11+
12+
## Version introduced
13+
14+
.NET 10 Preview 7
15+
16+
## Previous behavior
17+
18+
Previously, you could use <xref:Microsoft.AspNetCore.HttpOverrides.IPNetwork?displayProperty=fullName> and <xref:Microsoft.AspNetCore.Builder.ForwardedHeadersOptions.KnownNetworks> to configure known networks for the forwarded headers middleware:
19+
20+
```csharp
21+
app.UseForwardedHeaders(new ForwardedHeadersOptions
22+
{
23+
KnownNetworks.Add(new(IPAddress.Loopback, 8))
24+
});
25+
```
26+
27+
## New behavior
28+
29+
Starting in .NET 10, if you use [the obsolete APIs](#affected-apis) in your code, you'll get warning `ASPDEPR005` at compile time:
30+
31+
> warning ASPDEPR005: Please use KnownIPNetworks instead. For more information, visit <https://aka.ms/aspnet/deprecate/005>.
32+
33+
Use the <xref:System.Net.IPNetwork?displayProperty=fullName> type and `KnownIPNetworks` property instead.
34+
35+
## Type of breaking change
36+
37+
This change can affect [source compatibility](../../categories.md#source-compatibility).
38+
39+
## Reason for change
40+
41+
<xref:System.Net.IPNetwork?displayProperty=fullName> has replaced the <xref:Microsoft.AspNetCore.HttpOverrides.IPNetwork?displayProperty=fullName> type that was implemented for <xref:Microsoft.AspNetCore.HttpOverrides.ForwardedHeadersMiddleware>.
42+
43+
## Recommended action
44+
45+
Change to using <xref:System.Net.IPNetwork?displayProperty=fullName> and `KnownIPNetworks`.
46+
47+
## Affected APIs
48+
49+
- <xref:Microsoft.AspNetCore.HttpOverrides.IPNetwork?displayProperty=fullName>
50+
- <xref:Microsoft.AspNetCore.Builder.ForwardedHeadersOptions.KnownNetworks?displayProperty=fullName>

docs/core/compatibility/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ items:
2020
href: aspnet-core/10/iactioncontextaccessor-obsolete.md
2121
- name: IncludeOpenAPIAnalyzers property and MVC API analyzers are deprecated
2222
href: aspnet-core/10/openapi-analyzers-deprecated.md
23+
- name: IPNetwork and ForwardedHeadersOptions.KnownNetworks are obsolete
24+
href: aspnet-core/10/ipnetwork-knownnetworks-obsolete.md
2325
- name: Microsoft.Extensions.ApiDescription.Client package deprecated
2426
href: aspnet-core/10/apidescription-client-deprecated.md
2527
- name: Razor run-time compilation is obsolete

0 commit comments

Comments
 (0)