Skip to content

Commit 6c84d4d

Browse files
WN 11 P1: IOutputCachePolicyProvider, TimeProvider, Auto-trust (#36760)
* WN 11 P1: IOutputCachePolicyProvider, TimeProvider, Auto-trust * Update file name * Update aspnetcore/release-notes/aspnetcore-11/includes/output-cache-policy-provider.md Co-authored-by: Tom Dykstra <tdykstra@microsoft.com> --------- Co-authored-by: Tom Dykstra <tdykstra@microsoft.com>
1 parent 766306b commit 6c84d4d

4 files changed

Lines changed: 56 additions & 0 deletions

File tree

aspnetcore/release-notes/aspnetcore-11.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ This section describes new features for OpenAPI.
4343

4444
This section describes new features for authentication and authorization.
4545

46+
[!INCLUDE[](~/release-notes/aspnetcore-11/includes/identity-time-provider.md)]
47+
4648
## Miscellaneous
4749

4850
This section describes miscellaneous new features in .NET 11.
4951

52+
[!INCLUDE[](~/release-notes/aspnetcore-11/includes/output-cache-policy-provider.md)]
53+
54+
[!INCLUDE[](~/release-notes/aspnetcore-11/includes/development-certificate-trust.md)]
55+
5056
<!-- HOLD - The breaking changes article for 11.0 hasn't been created yet ...
5157
5258
https://learn.microsoft.com/dotnet/core/compatibility/breaking-changes
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
### Auto-trust development certificates in WSL
2+
3+
The development certificate setup now automatically trusts certificates in WSL (Windows Subsystem for Linux) environments. When you run `dotnet dev-certs https --trust` in WSL, the certificate is automatically installed and trusted in both the WSL environment and Windows, eliminating manual trust configuration.
4+
5+
```bash
6+
# Automatically trusts certificates in both WSL and Windows
7+
dotnet dev-certs https --trust
8+
```
9+
10+
This improvement streamlines the development experience when using WSL, removing a common friction point for developers working in Linux environments on Windows.
11+
12+
Thank you [@StickFun](https://github.com/StickFun) for this contribution!
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### `TimeProvider` support in ASP.NET Core Identity
2+
3+
ASP.NET Core Identity now uses `TimeProvider` instead of `DateTime` and `DateTimeOffset` for all time-related operations. This change makes Identity components more testable and provides better control over time in tests and specialized scenarios.
4+
5+
The following example shows how to use a fake `TimeProvider` for testing Identity features:
6+
7+
```csharp
8+
// In tests
9+
var fakeTimeProvider = new FakeTimeProvider(
10+
new DateTimeOffset(2024, 1, 1, 0, 0, 0, TimeSpan.Zero));
11+
12+
services.AddSingleton<TimeProvider>(fakeTimeProvider);
13+
services.AddIdentity<IdentityUser, IdentityRole>();
14+
15+
// Identity will now use the fake time provider
16+
```
17+
18+
By using `TimeProvider`, you can more easily write deterministic tests for time-sensitive Identity features such as token expiration, lockout durations, and security stamp validation.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
### `IOutputCachePolicyProvider` interface
2+
3+
ASP.NET Core in .NET 11 provides the [IOutputCachePolicyProvider](https://source.dot.net/#Microsoft.AspNetCore.OutputCaching/[IOutputCachePolicyProvider.cs](https://source.dot.net/#Microsoft.AspNetCore.OutputCaching/IOutputCachePolicyProvider.cs)` interface for implementing custom output caching policy selection logic. By using this interface, apps can determine the default base caching policy, check for the existence of named policies, and support advanced scenarios where policies must be resolved dynamically. Examples include loading policies from external configuration sources, databases, or applying tenant-specific caching rules.
4+
5+
The following code shows the `IOutputCachePolicyProvider` interface:
6+
7+
```csharp
8+
public interface IOutputCachePolicyProvider
9+
{
10+
IReadOnlyList<IOutputCachePolicy> GetBasePolicies();
11+
ValueTask<IOutputCachePolicy?> GetPolicyAsync(string policyName);
12+
}
13+
```
14+
15+
<!--
16+
UPDATE 11.0 - Add API cross-reference link when available:
17+
<xref:Microsoft.AspNetCore.OutputCaching.IOutputCachePolicyProvider>
18+
-->
19+
20+
Thank you [@lqlive](https://github.com/lqlive) for this contribution!

0 commit comments

Comments
 (0)