Skip to content

Commit 80c8928

Browse files
committed
config toc
1 parent 4b30e0e commit 80c8928

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

aspnetcore/diagnostics/asp0028.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
`IPv6Any` is preferred to `Any` because `Any` is slower than `IPv6Any`. In some cases, `Any` may not work at all. `Any` has performance problems due to the [underlying System types implementation](https://github.com/dotnet/runtime/issues/82404).
2+
3+
`127.0.0.1` is the IPv4 loopback address. `::1` is the IPv6 loopback address. `Any` is the wildcard address for IPv4. `IPv6Any` is the wildcard address for IPv6.
4+
5+
Currently, when using HTTP/1.x or HTTP/2.0:
6+
7+
* `localhost` resolve to `[::1]`.
8+
* `[::1]` isn't accepted by the server, which forces a retry using `127.0.0.1`, and the cycle continues.
9+
10+
Using `Any` with the preceding conditions is reported with a diagnostic message:
11+
12+
```csharp
13+
.UseKestrel().ConfigureKestrel(options =>
14+
{
15+
options.Listen(IPAddress.Any, ...);
16+
})
17+
```
18+
19+
## Rule description
20+
21+
The recommended way to configure Kestrel to listen for incoming connections on all available `IPv6` network interfaces is with `IPv6Any`.
22+
23+
## How to fix violations
24+
25+
For the problematic code, replace `Any` with `IPv6Any`:
26+
27+
```diff
28+
.UseKestrel().ConfigureKestrel(options =>
29+
{
30+
- options.Listen(IPAddress.Any, ...);
31+
+ options.Listen(IPAddress.IPv6Any, ...);
32+
})
33+
```
34+
35+
Alternatively, use the `ListenAnyIP` method without specifying any argument:
36+
37+
```diff
38+
.UseKestrel().ConfigureKestrel(options =>
39+
{
40+
- options.Listen(IPAddress.Any, ...);
41+
+ options.ListenAnyIP(...);
42+
})
43+
```
44+
45+
## When to suppress warnings
46+
47+
The `ASP0028` diagnostic has a Information level severity. Suppress warnings if your intention is to disable `IPv6` usage completely on the server, although this comes with the risk of the performance problems mentions in this article
48+
49+
`IPv6` can be disabled either system-wide, or for .NET only via the [AppCtx switch or environment variable](https://devblogs.microsoft.com/dotnet/dotnet-6-networking-improvements/#an-option-to-globally-disable-ipv6)

aspnetcore/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,8 @@ items:
14961496
uid: security/authentication/index
14971497
- name: Choose an identity solution
14981498
uid: security/how-to-choose-identity
1499+
- name: Configure OpenID
1500+
uid: security/authentication/configure-oidc-web-authentication
14991501
- name: ASP.NET Core Identity
15001502
items:
15011503
- name: Overview

0 commit comments

Comments
 (0)