Skip to content

Commit 215a71c

Browse files
authored
Merge pull request #35924 from dotnet/main
Merge to Live
2 parents 91be2c8 + d4bbd01 commit 215a71c

12 files changed

+189
-24
lines changed

aspnetcore/blazor/performance/index.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ For more information on the following performance meters, see <xref:log-mon/metr
5656

5757
`Microsoft.AspNetCore.Components` meter:
5858

59-
* `aspnetcore.components.navigation`: Tracks the total number of route changes in the app.
60-
* `aspnetcore.components.event_handler`: Measures the duration of processing browser events, including business logic.
59+
* `aspnetcore.components.navigate`: Tracks the total number of route changes in the app.
60+
* `aspnetcore.components.handle_event.duration`: Measures the duration of processing browser events, including business logic.
6161

6262
`Microsoft.AspNetCore.Components.Lifecycle` meter:
6363

64-
* `aspnetcore.components.update_parameters`: Measures the duration of processing component parameters, including business logic.
65-
* `aspnetcore.components.render_diff`: Tracks the duration of rendering batches.
64+
* `aspnetcore.components.update_parameters.duration`: Measures the duration of processing component parameters, including business logic.
65+
* `aspnetcore.components.render_diff.duration`: Tracks the duration of rendering batches.
66+
* `aspnetcore.components.render_diff.size`: Tracks the size of rendering batches.
6667

6768
`Microsoft.AspNetCore.Components.Server.Circuits` meter:
6869

@@ -80,7 +81,7 @@ The new activity tracing capabilities use the `Microsoft.AspNetCore.Components`
8081

8182
Circuit lifecycle tracing:
8283

83-
`Microsoft.AspNetCore.Components.CircuitStart`: Traces circuit initialization with the format `Circuit {circuitId}`.
84+
`Microsoft.AspNetCore.Components.StartCircuit`: Traces circuit initialization with the format `Circuit {circuitId}`.
8485

8586
Tags:
8687

@@ -96,7 +97,7 @@ Usage: Links other Blazor traces of the same session/circuit to HTTP and SignalR
9697

9798
Navigation tracing:
9899

99-
`Microsoft.AspNetCore.Components.RouteChange`: Tracks route changes with the format `Route {route} -> {componentType}`.
100+
`Microsoft.AspNetCore.Components.Navigate`: Tracks route changes with the format `Route {route} -> {componentType}`.
100101

101102
Tags:
102103

@@ -119,14 +120,12 @@ Event handling tracing:
119120
Tags:
120121

121122
* `aspnetcore.components.attribute.name`: Name of the HTML attribute that triggers the event (example: `onClick`).
122-
* `aspnetcore.components.method`: C# method name of the handler.
123+
* `code.function.name`: C# method name of the handler.
123124
* `aspnetcore.components.type`: Full name of target C# component that receives the event.
124125
* `error.type`: Exception type full name (optional).
125126

126127
Links:
127128

128-
* HTTP trace
129-
* SignalR trace
130129
* Circuit trace
131130
* Route trace
132131

aspnetcore/release-notes/aspnetcore-10.0.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ This section describes new features for minimal APIs.
4545

4646
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/validation-package-move.md)]
4747

48+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/enhance-validation-classes-records.md)]
49+
4850
## OpenAPI
4951

5052
This section describes new features for OpenAPI.
@@ -61,11 +63,15 @@ This section describes new features for OpenAPI.
6163

6264
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/xml-comment-generator.md)]
6365

66+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/formdata-enum-parameters.md)]
67+
6468
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/OpenApiSchemasInTransformers.md)]
6569

66-
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/OpenApiNetUpdatePrev.md)]
70+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/upgrade-microsoft-openapi-2.md)]
6771

68-
## Authentication and authorization metrics
72+
## Authentication and authorization
73+
74+
### Authentication and authorization metrics
6975

7076
Metrics have been added for certain authentication and authorization events in ASP.NET Core. With this change, you can now obtain metrics for the following events:
7177

@@ -84,10 +90,18 @@ The following image shows an example of the Authenticated request duration metri
8490

8591
For more information, see <xref:log-mon/metrics/built-in#microsoftaspnetcoreauthorization>.
8692

93+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/avoid-cookie-login-redirects.md)]
94+
8795
## Miscellaneous
8896

8997
This section describes miscellaneous new features in .NET 10.
9098

99+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/exception-handler.md)]
100+
101+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/top-level-domain.md)]
102+
103+
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/pipe-reader.md)]
104+
91105
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/memory-eviction.md)]
92106

93107
[!INCLUDE[](~/release-notes/aspnetcore-10/includes/httpsys.md)]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
### Avoid cookie login redirects for known API endpoints
2+
3+
By default, unauthenticated and unauthorized requests made to known API endpoints protected by cookie authentication now result in 401 and 403 responses rather than redirecting to a login or access denied URI.
4+
5+
This change was [highly requested](https://github.com/dotnet/aspnetcore/issues/9039), because redirecting unauthenticated requests to a login page doesn't usually make sense for API endpoints which typically rely on 401 and 403 status codes rather than HTML redirects to communicate auth failures.
6+
7+
Known API [Endpoints](https://learn.microsoft.com/aspnet/core/fundamentals/routing) are identified using the new `IApiEndpointMetadata` interface, and metadata implementing the new interface has been added automatically to the following:
8+
9+
- `[ApiController]` endpoints
10+
- Minimal API endpoints that read JSON request bodies or write JSON responses
11+
- Endpoints using `TypedResults` return types
12+
- SignalR endpoints
13+
14+
When `IApiEndpointMetadata` is present, the cookie authentication handler now returns appropriate HTTP status codes (401 for unauthenticated requests, 403 for forbidden requests) instead of redirecting.
15+
16+
If you want to prevent this new behavior, and always redirect to the login and access denied URIs for unauthenticated or unauthorized requests regardless of the target endpoint, you can override the `RedirectToLogin` and `RedirectToAccessDenied` events as follows:
17+
18+
```csharp
19+
builder.Services.AddAuthentication()
20+
.AddCookie(options =>
21+
{
22+
options.Events.OnRedirectToLogin = context =>
23+
{
24+
context.Response.Redirect(context.RedirectUri);
25+
return Task.CompletedTask;
26+
};
27+
28+
options.Events.OnRedirectToAccessDenied = context =>
29+
{
30+
context.Response.Redirect(context.RedirectUri);
31+
return Task.CompletedTask;
32+
};
33+
});
34+
```
35+
36+
For more information about this breaking change, see [ASP.NET Core breaking changes announcement](https://github.com/aspnet/Announcements/issues/525).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Enhanced validation for classes and records
2+
3+
Validation attributes can now be applied to both classes and records with consistent code generation and validation behavior. This enhancement improves flexibility when designing models using records in ASP.NET Core apps.
4+
5+
Community contribution: Thanks to [@marcominerva](https://github.com/marcominerva)!
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
### Configure suppressing exception handler diagnostics
2+
3+
A new configuration option has been added to the [ASP.NET Core exception handler middleware](https://learn.microsoft.com/aspnet/core/fundamentals/error-handling#exception-handler-page) to control diagnostic output: `ExceptionHandlerOptions.SuppressDiagnosticsCallback`. This callback is passed context about the request and exception, allowing you to add logic that determines whether the middleware should write exception logs and other telemetry.
4+
5+
This setting is useful when you know an exception is transient or has been handled by the exception handler middleware, and don't want error logs written to your observability platform.
6+
7+
Additionally, the middleware's default behavior has changed: it no longer writes exception diagnostics for exceptions handled by `IExceptionHandler`. Based on user feedback, logging handled exceptions at the error level was often undesirable when `IExceptionHandler.TryHandleAsync` returned `true`.
8+
9+
You can revert to the previous behavior by configuring `SuppressDiagnosticsCallback`:
10+
11+
```csharp
12+
app.UseExceptionHandler(new ExceptionHandlerOptions
13+
{
14+
SuppressDiagnosticsCallback = context => false;
15+
});
16+
```
17+
18+
For more information about this breaking change, see https://github.com/aspnet/Announcements/issues/524.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
### Form data enum parameters use actual enum type in OpenAPI
2+
3+
Form data parameters in MVC controller actions now generate OpenAPI metadata using the actual enum type instead of defaulting to string.
4+
5+
Community contribution: Thanks to [@ascott18](https://github.com/ascott18)!
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
### Json+PipeReader deserialization support in MVC and Minimal
2+
3+
PR: https://github.com/dotnet/aspnetcore/pull/62895
4+
5+
See https://github.com/dotnet/core/blob/dotnet10-p7-libraries/release-notes/10.0/preview/preview7/libraries.md#pipereader-support-for-json-serializer
6+
7+
MVC, Minimal APIs, and the `HttpRequestJsonExtensions.ReadFromJsonAsync` methods have all been updated to use the new Json+PipeReader support without requiring any code changes from applications.
8+
9+
For the majority of applications this should have no impact on behavior. However, if the application is using a custom `JsonConverter`, there is a chance that the converter doesn't handle [Utf8JsonReader.HasValueSequence](https://learn.microsoft.com/dotnet/api/system.text.json.utf8jsonreader.hasvaluesequence) correctly. This can result in missing data and errors like `ArgumentOutOfRangeException` when deserializing.
10+
11+
The quick workaround (especially if you don't own the custom `JsonConverter` being used) is to set the `"Microsoft.AspNetCore.UseStreamBasedJsonParsing"` [AppContext](https://learn.microsoft.com/dotnet/api/system.appcontext?view=net-9.0) switch to `"true"`. This should be a temporary workaround and the `JsonConverter`(s) should be updated to support `HasValueSequence`.
12+
13+
To fix `JsonConverter` implementations, there is the quick fix which allocates an array from the `ReadOnlySequence` and would look something like:
14+
```csharp
15+
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
16+
{
17+
var span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan;
18+
// previous code
19+
}
20+
```
21+
22+
Or the more complicated (but performant) fix which would involve having a separate code path for the `ReadOnlySequence` handling:
23+
```csharp
24+
public override T? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
25+
{
26+
if (reader.HasValueSequence)
27+
{
28+
reader.ValueSequence;
29+
// ReadOnlySequence optimized path
30+
}
31+
else
32+
{
33+
reader.ValueSpan;
34+
// ReadOnlySpan optimized path
35+
}
36+
}
37+
```
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
### Response description on ProducesResponseType for API controllers
1+
### Response description on `ProducesResponseType` for API controllers
22

3-
The [ProducesAttribute](/dotnet/api/microsoft.aspnetcore.mvc.producesattribute-1), [ProducesResponseTypeAttribute](/dotnet/api/microsoft.aspnetcore.mvc.producesresponsetypeattribute-1), and [ProducesDefaultResponseType](/dotnet/api/microsoft.aspnetcore.mvc.producesdefaultresponsetypeattribute) attributes now accept an optional string parameter, `Description`, that will set the description of the response. Here's an example:
3+
The <xref:Microsoft.AspNetCore.Mvc.ProducesAttribute>, <xref:Microsoft.AspNetCore.Mvc.ProducesResponseTypeAttribute>, and <xref:Microsoft.AspNetCore.Mvc.ProducesDefaultResponseTypeAttribute> now accept an optional string parameter, `Description`, that sets the description of the response:
44

55
```csharp
66
[HttpGet(Name = "GetWeatherForecast")]
77
[ProducesResponseType<IEnumerable<WeatherForecast>>(StatusCodes.Status200OK,
8-
Description = "The weather forecast for the next 5 days.")]
8+
Description = "The weather forecast for the next 5 days.")]
99
public IEnumerable<WeatherForecast> Get()
1010
{
1111
```
1212

13-
And the generated OpenAPI:
13+
Generated OpenAPI data:
1414

1515
```json
16-
"responses": {
17-
"200": {
18-
"description": "The weather forecast for the next 5 days.",
19-
"content": {
16+
"responses": {
17+
"200": {
18+
"description": "The weather forecast for the next 5 days.",
19+
"content": {
2020
```
21-
[Minimal APIs](https://github.com/dotnet/aspnetcore/issues/58724) currently don't support `ProducesResponseType`.
2221

23-
[Community contribution](https://github.com/dotnet/aspnetcore/pull/58193) by [Sander ten Brinke](https://github.com/sander1095) 🙏
22+
This functionality is supported in both [API controllers](xref:web-api/index#apicontroller-attribute) and [Minimal APIs](xref:fundamentals/minimal-apis/overview). For Minimal APIs, the `Description` property is correctly set even when the attribute's type and the inferred return type aren't an exact match.
23+
24+
[Community contribution (`dotnet/aspnetcore` #58193)](https://github.com/dotnet/aspnetcore/pull/58193) by [Sander ten Brinke](https://github.com/sander1095).
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
### Support for the .localhost Top-Level Domain
2+
3+
The `.localhost` top-level domain (TLD) is defined in [RFC2606](https://www.rfc-editor.org/rfc/rfc2606) and [RFC6761](https://www.rfc-editor.org/rfc/rfc6761) as being reserved for testing purposes and available for users to use locally as they would any other domain name. This means using a name like `myapp.localhost` locally that resolves to the IP loopback address is allowed and expected according to these RFCs. Additionally, modern evergreen browsers already automatically resolve any `*.localhost` name to the IP loopback address (`127.0.0.1`/`::1`), effectively making them an alias for any service already being hosted at `localhost` on the local machine, i.e. any service responding to `http://localhost:6789` will also respond to `http://anything-here.localhost:6789`, assuming no further specific hostname verification or enforcement is being performed by the service.
4+
5+
ASP.NET Core has been updated in .NET 10 preview 7 to better support the `.localhost` TLD, such that it can now be easily used when creating and running ASP.NET Core applications in your local development environment. Having different apps running locally be resolvable via different names allows for better separation of some domain-name-associated website assets, e.g. cookies, and makes it easier to identify which app you're browsing via the name displayed in the browser address bar.
6+
7+
ASP.NET Core's built-in HTTP server, Kestrel, will now correctly treat any `*.locahost` name set via [supported endpoint configuration mechanisms](https://learn.microsoft.com/aspnet/core/fundamentals/servers/kestrel/endpoints#configure-endpoints) as the local loopback address and thus bind to it rather than all external address (i.e. bind to `127.0.0.1`/`::1` rather than `0.0.0.0`/`::`). This includes the `"applicationUrl"` property in [launch profiles configured in a *launchSettings.json* file](https://learn.microsoft.com/aspnet/core/fundamentals/environments#development-and-launchsettingsjson), and the `ASPNETCORE_URLS` environment variable. When configured to listen on a `.localhost` address, Kestrel will log an information message for both the `.localhost` **and** `localhost` addresses, to make it clear that both names can be used.
8+
9+
*Note that while web browsers will automatically resolve `*.localhost` names to the local loopback address, other applications may treat `*.localhost` names as a regular domain names and attempt to resolve them via their corresponding DNS stack. If your DNS configuration does not resolve `*.localhost` names to an address then they will fail to connect. You can continue to use the regular `localhost` name to address your applications when not in a web browser.*
10+
11+
The [ASP.NET Core HTTPS development certificate](https://learn.microsoft.com/aspnet/core/security/enforcing-ssl#trust-the-aspnet-core-https-development-certificate) (including the `dotnet dev-certs https` command) have been updated to ensure the certificate is valid for use with the `*.dev.localhost` domain name. After installing .NET 10 SDK preview 7, trust the new developer certificate by running `dotnet dev-certs https --trust` at the command line to ensure your system is configured to trust the new certificate.
12+
13+
*Note that the certificate lists the `*.dev.localhost` name as a Subject Alternative Name (SAN) rather than `*.localhost` as it's invalid to have wildcard certificates for top-level domain names*
14+
15+
The project templates for *ASP.NET Core Empty* (`web`) and *Blazor Web App* (`blazor`) have been updated with a new option that when specified configures the created project to use the `.dev.localhost` domain name suffix, combining it with the project name to allow the app to be browsed to at an address like `https://myapp.dev.localhost:5036`:
16+
17+
```
18+
$ dotnet new web -n MyApp --localhost-tld
19+
The template "ASP.NET Core Empty" was created successfully.
20+
21+
Processing post-creation actions...
22+
Restoring D:\src\MyApp\MyApp.csproj:
23+
Restore succeeded.
24+
25+
$ cd .\MyApp\
26+
$ dotnet run --launch-profile https
27+
info: Microsoft.Hosting.Lifetime[14]
28+
Now listening on: https://myapp.dev.localhost:7099
29+
info: Microsoft.Hosting.Lifetime[14]
30+
Now listening on: https://localhost:7099/
31+
info: Microsoft.Hosting.Lifetime[14]
32+
Now listening on: http://myapp.dev.localhost:5036
33+
info: Microsoft.Hosting.Lifetime[14]
34+
Now listening on: http://localhost:5036/
35+
info: Microsoft.Hosting.Lifetime[0]
36+
Application started. Press Ctrl+C to shut down.
37+
info: Microsoft.Hosting.Lifetime[0]
38+
Hosting environment: Development
39+
info: Microsoft.Hosting.Lifetime[0]
40+
Content root path: D:\src\local\10.0.1xx\MyApp
41+
```
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Upgrade Microsoft.OpenApi to 2.0.0
2+
3+
The [`Microsoft.OpenApi`](https://www.nuget.org/packages/Microsoft.OpenApi/) library used for OpenAPI document generation in ASP.NET Core has been upgraded to version 2.0.0 (GA).
4+
With this update to the GA version, no further breaking changes are expected in OpenAPI document generation.

0 commit comments

Comments
 (0)