.NET 11: Updates Developers Should Know
Explore important .NET 11 updates through practical scenarios, code examples, developer explanations, and real-world considerations—not just release-note summaries.
Learning Roadmap
1. Runtime Async: async/await implementation evolves
Runtime Async is one of the notable runtime changes. The runtime can
manage async suspension and resumption instead of relying solely on
compiler-generated state machines. The goal is reduced overhead in
relevant paths, improved diagnostics, and cleaner async stack traces.
This is an implementation change: your everyday async/await
code generally remains familiar.
What it means for developers: you don't need to rewrite your methods just to use Runtime Async. Learn how the runtime behavior, performance characteristics, and debugging experience may change. Benchmark your own workloads instead of assuming every method will be faster.
Runtime Async is a runtime feature with its own opt-in/support details described in the release documentation.
Explore it with code: asynchronous I/O
Start with a familiar asynchronous method and observe what happens while it waits for an I/O operation. Compare it with a blocking approach and think about why freeing a thread while waiting can help a server handle more concurrent requests.
// Simulate an I/O-bound operation
public async Task<string> GetDataAsync()
{
await Task.Delay(2000); // Simulates waiting for I/O
return "Data received";
}
var result = await GetDataAsync();
Console.WriteLine(result);
Try it yourself: Replace the delay with an HTTP or
database call. Avoid using Task.Run as a blanket fix for
I/O-bound work, and benchmark realistic workloads before drawing
performance conclusions.
2. Native OpenTelemetry tracing in ASP.NET Core
ASP.NET Core adds built-in OpenTelemetry semantic-convention attributes to HTTP server activities. This improves trace context—such as HTTP method, route/path, response status, and server address—without requiring the ASP.NET Core instrumentation package for that framework activity metadata. You still configure exporters and your observability pipeline.
builder.Services.AddOpenTelemetry() .WithTracing(tracing => tracing .AddSource("Microsoft.AspNetCore") .AddConsoleExporter());
Use case: investigate slow endpoints, correlate request traces, and understand where latency is introduced across services. A console exporter is useful for local learning; production usually sends telemetry to an observability backend.
Explore it with code: add tracing to an API
Tracing helps you follow a request through the application. Configure tracing for the ASP.NET Core activity source and an exporter while learning locally.
builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddSource("Microsoft.AspNetCore")
.AddHttpClientInstrumentation()
.AddConsoleExporter());
Explore: call an endpoint, inspect the trace, and identify its duration. Next, add an outgoing HTTP call and compare the spans. In production, configure an appropriate exporter and protect telemetry from exposing sensitive data.
3. Output Caching: custom policy selection
Output caching can reduce repeated work when responses are safe to
cache. .NET 11 adds an
IOutputCachePolicyProvider abstraction for
selecting/resolving policies, enabling scenarios such as policies from
configuration or tenant-aware rules. Be careful: personalized or
authorization-sensitive responses must not be shared accidentally.
public interface IOutputCachePolicyProvider
{
IReadOnlyList<IOutputCachePolicy> GetBasePolicies();
ValueTask<IOutputCachePolicy?> GetPolicyAsync(
string policyName);
}
Use case: teams can centralize cache policy resolution rather than hard-code every policy choice in endpoint setup. This interface is a building block; it doesn't automatically create a caching strategy for your application.
Explore it with code: response caching behavior
Output caching is useful when the same response can safely be reused. The following illustrates the basic endpoint setup; it is a learning example, separate from the new policy-provider abstraction discussed above.
builder.Services.AddOutputCache();
var app = builder.Build();
app.UseOutputCache();
app.MapGet("/catalog", () =>
GetCatalogAsync())
.CacheOutput();
Explore: make repeated requests and compare the work performed. Then experiment with expiration and cache variation. Never cache personalized or authorization-sensitive content in a shared cache unless the cache policy explicitly isolates it.
4. Async validation: rules that need I/O
DataAnnotations gains asynchronous validation support for checks that need to await external work, such as verifying a value against a service. This helps avoid forcing I/O-bound validation into a synchronous rule pattern.
public sealed class UniqueHandleAttribute : AsyncValidationAttribute { // Implement IsValidAsync to check the handle asynchronously // against a service/repository, and return ValidationResult. }
Use this for cases such as uniqueness or remote verification—but don't use a database uniqueness check as a replacement for a database unique constraint. Validation can race, so enforce critical invariants at the data layer too.
Explore it with code: a service-level uniqueness check
Even when a framework supports asynchronous validation, a repository or application service is often a clear place to perform checks that require database access. This example demonstrates the idea with a service method:
public async Task<bool> IsHandleAvailableAsync(
string handle)
{
var existing = await repository
.FindByHandleAsync(handle);
return existing is null;
}
Explore: use the check when returning a helpful validation message, then add a unique index/constraint in the database. Two requests can pass the check at nearly the same time, so the database remains the final authority.
5. System.Text.Json: more flexible serialization
JSON updates include expanded union support, JSON Lines (JSONL) output, additional polymorphism and source-generation capabilities, and more serialization controls. These matter for APIs, messaging, large data workflows, and reducing manual serialization work.
// JSON Lines: one JSON value per line, useful for streaming/log-style data. { "event": "created", "id": 101 } { "event": "updated", "id": 101 }
JSONL is a format concept: unlike one large JSON array, each line can be handled as an individual JSON value, making streaming and incremental processing practical.
Explore it with code: serialize and deserialize a model
using System.Text.Json;
var product = new Product
{
Id = 42,
Name = "Keyboard"
};
var json = JsonSerializer.Serialize(product);
Console.WriteLine(json);
var restored = JsonSerializer.Deserialize<Product>(json);
Explore: try custom property names, ignore null values, add a custom converter, and compare normal serialization with source-generated serialization. For JSON Lines, process each line independently instead of loading an entire large file into memory.
6. Networking and HTTP improvements
Request-body compression wrappers
New networking APIs make it easier to work with compressed outgoing request bodies in applicable HTTP scenarios.
HTTP connection eviction
More configurable connection management helps apps control when pooled connections are removed.
Typed DNS resolution
New DNS APIs provide typed record-resolution options across supported operating systems.
HTTP/3 / QUIC controls
New stream priority support gives additional control in supported HTTP/3 scenarios.
Developer takeaway: these are mostly platform-level APIs. Most Web API developers won't need to change routine controllers, but they can matter for integrations, high-throughput clients, and infrastructure-sensitive workloads.
Explore it with code: use HttpClient safely
For application code, prefer a configured client from
IHttpClientFactory rather than creating and disposing a new
HttpClient for every request.
builder.Services.AddHttpClient<CatalogClient>();
public sealed class CatalogClient(HttpClient http)
{
public async Task<string> GetCatalogAsync()
{
using var response = await http.GetAsync("/catalog");
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
}
Explore: add a timeout, cancellation token, and error handling. Learn where retries are appropriate, and avoid retrying non-idempotent operations without a deliberate strategy.
7. MemoryCache metrics with OpenTelemetry
MemoryCache can emit OTel-compatible metrics when
statistics tracking is enabled, including cache hit/miss information,
evictions, entry count, and estimated size. This can help diagnose cache
behavior rather than guess.
var cache = new MemoryCache( new MemoryCacheOptions { TrackStatistics = true });
Enable statistics when useful for monitoring; consider measurement overhead and your telemetry configuration.
Explore it with code: understand cache hits and misses
if (!cache.TryGetValue("catalog", out List<Product>? products))
{
products = await LoadProductsAsync();
cache.Set("catalog", products,
TimeSpan.FromMinutes(5));
}
// A cache hit avoids loading the data again.
Explore: run the code twice and observe whether the data loader is called both times. Then test expiration, invalidation after updates, and how cache size changes. Cache only data whose freshness and sharing behavior are acceptable.
8. CLI and developer workflow updates
Pass environment variables with dotnet run
The new -e option helps run apps with environment
values from the command line.
dotnet run -e ASPNETCORE_ENVIRONMENT=Development
Solution filters (.slnf)
CLI support improves working with solution filters—useful in large repositories where you don't always want to load every project.
dotnet watch
Workflow enhancements include better app-host integration and recovery behavior in supported scenarios.
File-based apps
File-based app workflows continue to expand, including include/reference support and formatting improvements.
Explore it with code: protect an endpoint with a policy
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("AdminOnly", policy =>
policy.RequireRole("Admin"));
});
app.MapGet("/admin", () => "Admin area")
.RequireAuthorization("AdminOnly");
Explore: test the endpoint as an anonymous user, an authenticated user without the Admin role, and an Admin user. Authentication establishes who the caller is; authorization decides whether that caller is allowed to perform the action.
9. Authorization policy attributes have wider reach
IAuthorizationRequirementData / related requirement-data
attributes can be applied in more ASP.NET Core contexts, including
SignalR hubs and methods, MVC controllers and actions, and Blazor
authorization components. This helps teams reuse policy definitions more
consistently—but authorization still needs deliberate policy design and
tests.
Quick comparison: which updates should you explore first?
| Feature | Why it matters | Priority for API developers |
|---|---|---|
| Runtime Async | Runtime execution, async performance and diagnostics | High—understand, benchmark |
| Native ASP.NET Core tracing | Observability and request troubleshooting | High—hands-on |
| Output Cache policy provider | Flexible cache policy resolution | High—if caching APIs |
| Async validation | Validation that awaits external checks | High—practical use cases |
| System.Text.Json | Serialization flexibility, unions, JSONL | Medium–High |
| Networking APIs | Control for HTTP, DNS, and connections | Medium—specialized workloads |
| MemoryCache metrics | Observe cache behavior | High—when using caching |
| CLI improvements | Developer workflow and large-repo productivity | Medium—try them |
| Authorization attributes | Policy reuse across more framework surfaces | High—security-sensitive |
Try It Yourself: Mini Exploration Checklist
Use a small Web API project to turn this overview into hands-on learning. You don't need to implement every item at once—choose one topic, experiment, and record what you observe.
- Create a small endpoint and test asynchronous I/O with cancellation.
- Enable tracing and inspect the request activity and duration.
- Apply output caching to a safe endpoint and test expiration.
- Perform an asynchronous availability check, then enforce the rule with a database constraint.
- Serialize and deserialize a model; experiment with JSON options.
-
Use
IHttpClientFactoryto call another endpoint and handle failures. - Measure cache behavior by testing repeated requests and expiration.
- Apply an authorization policy and test different caller permissions.
Conclusion
.NET 11 is not only about new language syntax. Runtime execution, diagnostics, validation, caching, networking, JSON, authorization, and tooling all evolve. For working backend developers, the best value comes from understanding how these updates affect the reliability, maintainability, observability, and performance of everyday services. Use this article as an overview, then explore each feature by writing code, testing behavior, and considering its real-world trade-offs.