Events
Power BI DataViz World Championships
Feb 14, 4 PM - Mar 31, 4 PM
With 4 chances to enter, you could win a conference package and make it to the LIVE Grand Finale in Las Vegas
Learn moreThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
This article highlights the most significant changes in ASP.NET Core 10.0 with links to relevant documentation.
This article will be updated as new preview releases are made available. See the Asp.Net Core announcement page until this page is updated.
This section describes new features for Blazor.
Apply a stylesheet class to a row of the grid based on the row item using the new RowClass
parameter. In the following example, the GetRowCssClass
method is called on each row to conditionally apply a stylesheet class based on the row item:
<QuickGrid ... RowClass="GetRowCssClass">
...
</QuickGrid>
@code {
private string GetRowCssClass(MyGridItem item) =>
item.IsArchived ? "row-archived" : null;
}
For more information, see ASP.NET Core Blazor `QuickGrid` component.
In prior releases of .NET, the Blazor script is served from an embedded resource in the ASP.NET Core shared framework. In .NET 10 or later, the Blazor script is served as a static web asset with automatic compression and fingerprinting.
For more information, see the following resources:
The [Route]
attribute now supports route syntax highlighting to help visualize the structure of the route template:
This section describes new features for SignalR.
This section describes new features for minimal APIs.
This section describes new features for OpenAPI.
ASP.NET Core has added support for generating OpenAPI version 3.1 documents in .NET 10. Despite the minor version bump, OpenAPI 3.1 is a significant update to the OpenAPI specification, in particular with full support for JSON Schema draft 2020-12.
Some of the changes you will see in the generated OpenAPI document include:
nullable: true
property in the schema.nullable: true
property, they have a type
keyword whose value is an array that includes null
as one of the types.With this feature, the default OpenAPI version for generated documents is3.1
. The version can be changed by explicitly setting the OpenApiVersion property of the OpenApiOptions in the configureOptions
delegate parameter of AddOpenApi.
builder.Services.AddOpenApi(options =>
{
// Specify the OpenAPI version to use.
options.OpenApiVersion = Microsoft.OpenApi.OpenApiSpecVersion.OpenApi3_0;
});
When generating the OpenAPI document at build time, the OpenAPI version can be selected by setting the --openapi-version
in the OpenApiGenerateDocumentsOptions
MSBuild item.
<!-- Configure build-time OpenAPI generation to produce an OpenAPI 3.0 document. -->
<OpenApiGenerateDocumentsOptions>--openapi-version OpenApi3_0</OpenApiGenerateDocumentsOptions>
OpenAPI 3.1 support was primarly added in the following PR.
Support for OpenAPI 3.1 requires an update to the underlying OpenAPI.NET library to a new major version, 2.0. This new version has some breaking changes from the previous version. The breaking changes may impact apps if they have any document, operation, or schema transformers.
One of the most significant changes is that the OpenApiAny
class has been dropped in favor of using JsonNode
directly. Transformers that use OpenApiAny
need to be updated to use JsonNode
. The following diff shows the changes in schema transformer from .NET 9 to .NET 10:
options.AddSchemaTransformer((schema, context, cancellationToken) =>
{
if (context.JsonTypeInfo.Type == typeof(WeatherForecast))
{
- schema.Example = new OpenApiObject
+ schema.Example = new JsonObject
{
- ["date"] = new OpenApiString(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")),
+ ["date"] = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"),
- ["temperatureC"] = new OpenApiInteger(0),
+ ["temperatureC"] = 0,
- ["temperatureF"] = new OpenApiInteger(32),
+ ["temperatureF"] = 32,
- ["summary"] = new OpenApiString("Bracing"),
+ []"summary"] = "Bracing",
};
}
return Task.CompletedTask;
});
Note that these changes are necessary even when only congfiguring the OpenAPI version to 3.0.
ASP.NET now supports serving the generated OpenAPI document in YAML format. YAML can be more concise than JSON, eliminating curly braces and quotation marks when these can be inferred. YAML also supports multi-line strings, which can be useful for long descriptions.
To configure an app to serve the generated OpenAPI document in YAML format, specify the endpoint in the MapOpenApi call with a ".yaml" or ".yml" suffix, as shown in the following example:
app.MapOpenApi("/openapi/{documentName}.yaml");
Support for:
See this PR which added support for serving the generated OpenAPI document in YAML format.
The ProducesAttribute, ProducesResponseTypeAttribute, and ProducesDefaultResponseType attributes now accept an optional string parameter, Description
, that will set the description of the response. Here's an example:
[HttpGet(Name = "GetWeatherForecast")]
[ProducesResponseType<IEnumerable<WeatherForecast>>(StatusCodes.Status200OK, Description = "The weather forecast for the next 5 days.")]
public IEnumerable<WeatherForecast> Get()
{
And the generated OpenAPI:
"responses": {
"200": {
"description": "The weather forecast for the next 5 days.",
"content": {
Community contribution by Sander ten Brinke 🙏
This section describes new features for authentication and authorization.
This section describes miscellaneous new features in ASP.NET Core 10.0.
.NET 10 now has better support for testing apps that use top-level statements. Previously developers had to manually add public partial class Program
to the Program.cs
file so that the test project could reference the Program class
. public partial class Program
was required because the top-level statement feature in C# 9 generated a Program class
that was declared as internal.
In .NET 10, a source generator is used to generate the public partial class Program
declaration if the programmer didn't declare it explicitly. Additionally, an analyzer was added to detect when public partial class Program
is declared explicitly and advise the developer to remove it.
The following PRs contribited to this feature:
Use the new RedirectHttpResult.IsLocalUrl(url)
helper method to detect if a URL is local. A URL is considered local if the following are true:
URLs using virtual paths "~/"
are also local.
IsLocalUrl
is useful for validating URLs before redirecting to them to prevent open redirection attacks.
if (RedirectHttpResult.IsLocalUrl(url))
{
return Results.LocalRedirect(url);
}
Thank you @martincostello for this contribution!
ASP.NET Core feedback
ASP.NET Core is an open source project. Select a link to provide feedback:
Events
Power BI DataViz World Championships
Feb 14, 4 PM - Mar 31, 4 PM
With 4 chances to enter, you could win a conference package and make it to the LIVE Grand Finale in Las Vegas
Learn moreTraining
Module
Guide to Secure .NET Development with OWASP Top 10 - Training
Evaluate security risks that come with insecure application development patterns and practices