Skip to content

Commit 3eaf287

Browse files
authored
Add two ASP.NET breaking changes (#43370)
1 parent fea84a6 commit 3eaf287

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

docs/core/compatibility/9.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ If you're migrating an app to .NET 9, the breaking changes listed here might aff
2020
| Title | Type of change | Introduced version |
2121
|------------------------------------------------------------------------------------------|---------------------|--------------------|
2222
| [DefaultKeyResolution.ShouldGenerateNewKey has altered meaning](aspnet-core/9.0/key-resolution.md) | Behavioral change | Preview 3 |
23+
| [Dev cert export no longer creates folder](aspnet-core/9.0/certificate-export.md) | Behavioral change | RC 1 |
2324
| [HostBuilder enables ValidateOnBuild/ValidateScopes in development environment](aspnet-core/9.0/hostbuilder-validation.md) | Behavioral change | Preview 7 |
25+
| [Middleware types with multiple constructors](aspnet-core/9.0/middleware-constructors.md) | Behavioral change | RC 1 |
2426

2527
## Containers
2628

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
title: "Breaking change: Dev cert export no longer creates folder"
3+
description: Learn about the breaking change in ASP.NET Core 9 where exporting the development certificate no longer creates the target directory if it doesn't exist.
4+
ms.date: 11/6/2024
5+
---
6+
7+
# Dev cert export no longer creates folder
8+
9+
When you export the ASP.NET Core development certificate (which is used to enable HTTPS in local development), it no longer creates the directory into which the certificate is being exported if that directory doesn't exist.
10+
11+
This change first appears in .NET 8.0.10 and .NET 9 RC 1.
12+
13+
## Version introduced
14+
15+
.NET 9 RC 1
16+
17+
## Previous behavior
18+
19+
Previously, if the destination directory didn't exist when the `dotnet dev-certs` command was run, it was created (with permissions inherited from the containing directory). For example, *C:\\NonExistent\\* would have been created given the following command:
20+
21+
```dotnetcli
22+
dotnet dev-certs https -ep C:\NonExistent\cert.pfx
23+
```
24+
25+
## New behavior
26+
27+
Starting in .NET 9, if target directory doesn't exist, the export fails with a message like:
28+
29+
> There was an error exporting the HTTPS developer certificate to a file.
30+
31+
## Type of breaking change
32+
33+
This change is a [behavioral change](../../categories.md#behavioral-change).
34+
35+
## Reason for change
36+
37+
The development certificate is exported with its private key, so unauthorized access can be problematic. It might, nevertheless, be necessary to make it readable to multiple accounts, for example, if the consuming process won't be run as the current user. Rather than attempting to determine (and securely establish) permissions for the target directory, `dotnet dev-certs` requires that it already exist.
38+
39+
## Recommended action
40+
41+
Create the target directory (with appropriate permissions) before invoking `dotnet dev-certs`.
42+
43+
## Affected APIs
44+
45+
N/A
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
title: "Breaking change: Middleware types with multiple constructors"
3+
description: Learn about the breaking change in ASP.NET Core 9 where having multiple constructors in a middleware type can cause an exception at run time.
4+
ms.date: 11/6/2024
5+
---
6+
7+
# Middleware types with multiple constructors
8+
9+
Previously, when a middleware type with multiple satisfiable constructors was instantiated from the dependency injection container, the one with the most parameters was used. Now that only happens if the dependency injection container implements <xref:Microsoft.Extensions.DependencyInjection.IServiceProviderIsService>. If it doesn't, an exception is thrown at run time.
10+
11+
## Version introduced
12+
13+
.NET 9 RC 1
14+
15+
## Previous behavior
16+
17+
Previously, the first of the following two constructors was preferred (when both were satisfied) because it has more parameters.
18+
19+
```csharp
20+
public class CookiePolicyMiddleware
21+
{
22+
public CookiePolicyMiddleware(RequestDelegate next, IOptions<CookiePolicyOptions> options, ILoggerFactory factory)
23+
{
24+
// ...
25+
}
26+
27+
public CookiePolicyMiddleware(RequestDelegate next, IOptions<CookiePolicyOptions> options)
28+
{
29+
// ...
30+
}
31+
}
32+
```
33+
34+
## New behavior
35+
36+
Starting in .NET 9, neither constructor is preferred, and construction fails with an error like:
37+
38+
> System.InvalidOperationException: 'Multiple constructors accepting all given argument types have been found in type 'Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware'. There should only be one applicable constructor.'
39+
40+
## Type of breaking change
41+
42+
This change is a [behavioral change](../../categories.md#behavioral-change).
43+
44+
## Reason for change
45+
46+
The activation mechanism was changed to help support keyed dependency injection.
47+
48+
## Recommended action
49+
50+
If this happens and you can't upgrade to a dependency injection container that implements <xref:Microsoft.Extensions.DependencyInjection.IServiceProviderIsService>, you can add the <xref:Microsoft.Extensions.DependencyInjection.ActivatorUtilitiesConstructorAttribute> to the preferred constructor of the affected middleware type.
51+
52+
## Affected APIs
53+
54+
This change is known to cause errors when instantiating <xref:Microsoft.AspNetCore.CookiePolicy.CookiePolicyMiddleware?displayProperty=fullName> with [Autofac.Extensions.DependencyInjection](https://www.nuget.org/packages/Autofac.Extensions.DependencyInjection) 7.x.

docs/core/compatibility/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,12 @@ items:
1212
items:
1313
- name: DefaultKeyResolution.ShouldGenerateNewKey has altered meaning
1414
href: aspnet-core/9.0/key-resolution.md
15+
- name: Dev cert export no longer creates folder
16+
href: aspnet-core/9.0/certificate-export.md
1517
- name: HostBuilder enables ValidateOnBuild/ValidateScopes in development environment
1618
href: aspnet-core/9.0/hostbuilder-validation.md
19+
- name: Middleware types with multiple constructors
20+
href: aspnet-core/9.0/middleware-constructors.md
1721
- name: Containers
1822
items:
1923
- name: .NET 9 container images no longer install zlib
@@ -1028,8 +1032,12 @@ items:
10281032
items:
10291033
- name: DefaultKeyResolution.ShouldGenerateNewKey has altered meaning
10301034
href: aspnet-core/9.0/key-resolution.md
1035+
- name: Dev cert export no longer creates folder
1036+
href: aspnet-core/9.0/certificate-export.md
10311037
- name: HostBuilder enables ValidateOnBuild/ValidateScopes in development environment
10321038
href: aspnet-core/9.0/hostbuilder-validation.md
1039+
- name: Middleware types with multiple constructors
1040+
href: aspnet-core/9.0/middleware-constructors.md
10331041
- name: .NET 8
10341042
items:
10351043
- name: ConcurrencyLimiterMiddleware is obsolete

0 commit comments

Comments
 (0)