You can reduce the quality of photos to speed up the loading of your site
NET 5., the successor to .NET Core 3.1. And .NET Framework 4.8., Intends to bring a new cross-platform development experience to .NET developers. Offer. This brings new good features. Of course, in this article you will not learn everything about .NET 5., but you can focus on 5 to get a better understanding of what is happening.
Success in a media channel such as organic search depends on the content. In particular, the production of useful content has the ability to rank. In its recent algorithm updates, Google has focused heavily on promoting great content and natural links, and penalizing poor content with unspecified links.
If you own a website or work on a customer website, then you need to know the importance of SEO. Without proper SEO strategies, you can not get high rankings in Google.
Improved ASP.NET Core MVC and Razor
Model binding DateTime as UTC
Model binding supports binding of UTC time strings to DateTime. If the request contains a UTC time string, the binding model binds it to the UTC DateTime.
Model binding and validation with C# 9 record types
C # 9 record types can be used with the binding model in the MVC controller or Razor Page. Record types are a good way to record data models that are transmitted over the network. For example, PersonController uses Person record type with binding model and form validation:
Person / Index.cshtml file:
DynamicRouteValueTransformer introduced ASP.NET Core 3.1 as a way to use custom endpoints to dynamically select MVC controller action or Razor page. ASP.NET Core 5.0 applications can send status to DynamicRouteValueTransformer and filter the set of selected endpoints.
Web APIOpenAPI Specification Default
OpenAPI Specification is an industry standard for describing HTTP APIs and integrating them into complex business processes or third-party applications. OpenAPI is widely supported by all cloud providers and many APIs. Applications that publish OpenAPI documentation from web APIs have a variety of new opportunities that can be used with these APIs. Partner with Swashbuckle.AspNetCore open source project maintainers The ASP.NET Core API template includes NuGet dependencies on Swashbuckle. Swashbuckle is a popular NuGet open source package that dynamically distributes OpenAPI documentation. Swashbuckle does this by viewing API controllers and generating an OpenAPI document at runtime, or at build time using the Swashbuckle CLI.
In ASP.NET Core 5.0, web API templates enable OpenAPI support by default. To disable OpenAPI:
From Visual Studio: Uncheck Enable OpenAPI support
All csproj files. Created for web API projects include references to the Swashbuckle.AspNetCore NuGet package.
The generated code of the template contains the code in Startup.ConfigureServices that enables the production of the OpenAPI document:
The Swashbuckle middleware method adds Startup.Configure, which enables the following:
1. Document production process
2. Default Swagger UI screen in development mode
The generated code of the template does not explicitly display the API description when it is published for production.
Import Azure API Management
When OpenAPI projects enable the ASP.NET Core API, Visual Studio 2019 version 16.8 and later versions automatically provide an additional step in the release process. Developers using Azure API Management have the opportunity to automatically import APIs into Azure API Management during its publishing stream:
Better startup experience for web API projects
With OpenAPI enabled by default, the application startup experience (F5) is significantly improved for web API developers. With ASP.NET Core 5.0, the web API template is pre-configured to load the Swagger UI page. The Swagger UI page provides both documentation added to the published API, and allows testing APIs with a single click.
For NET 5. With a particular focus on sophisticated UI rendering and JSON serialization, significant improvements have been made to Blazor WebAssembly runtime performance. In performance tests, Blazor WebAssembly in NET 5. is two to three times faster for most scenarios.
Blazor now supports the definition of CSS styles that are restricted to a specific component. Component-specific CSS styles make it easy to reason about styles in the program and prevent unwanted side effects from global styles.
New InputFile component
The InputFile component allows you to read one or more files selected by the user for upload.
Understanding component rendering performance is enhanced by using Blazor framework internal virtualization support.
Ontoggle event support
Blazor events now support the ontoggle DOM event.
Set UI focus in Blazor applications
Use the FocusAsync method on elements to set the UI focus on elements.
Custom Attributes Validations
Custom validation classes are useful when integrated with CSS frameworks such as Bootstrap.
Blazor components now support the IAsyncDisposable interface for asynchronous distribution of allocated resources.
Form components support display name
The following internal components support displays with the DisplayName parameter:
Many performance improvements have been made in gRPC.
SignalR Hub filters
SignalR Hub filters, called Hub pipelines in ASP.NET SignalR, are features that allow code to run before and after called Hub methods. Executing code before and after the Hub methods being called is similar to the way middleware can execute code before and after an HTTP request. Common uses include logging, error handling, and argument validation.
SignalR parallel hub call
ASP.NET Core SignalR is now able to manage parallel hub calls. The default behavior can be changed to allow clients to call more than one hub method at a time:
Add Messagepack support to SignalR Java client
A new package, com.microsoft.signalr.messagepack, has added MessagePack support for the SignalR Java client. To use withHubProtocol (new MessagePackHubProtocol ()), MessagePack hub protocol. Add to connection builder:
Configurable endpoints: Kestrel can detect configuration changes sent to KestrelServerOptions.Configure and drop them from existing endpoints and connect them to new endpoints without the need to restart the program when the parameter is true, reloadOnChange. By default when using ConfigureWebHostDefaults or CreateDefaultBuilder, Kestrel closes under the "Kestrel" configuration section by enabling reloadOnChange. Applications must send reloadOnChange: true when KestrelServerOptions.Configure is called manually to receive reloadable endpoints.
Improved HTTP / 2 response headers.
Support for other endpoint types in socket transfers: Added to the new API introduced in System.Net.Sockets, Kestrel socket transfers allow you to connect to existing file management and Unix domain sockets. Support for connection to existing file management allows you to use existing Systemd integration without the need for libuv transport.
Special endpoint options for Kestrel via configuration
Support for configuration Endpoint-specific options for Kestrel have been added via configuration. The configuration of these endpoints includes the following:
HTTP protocols used
TLS protocols used
Client certificate modeConfig allows you to specify which certificate is selected based on the specified server name. The server name is part of the Server Name Indication (SNI) extension to the TLS protocol represented by the client.
The following example shows how to specify endpoint options using the configuration file:
Server Name Indication (SNI) is a TLS extension that includes a virtual domain as part of SSL negotiation. This means that the virtual domain name, or hostname, can be used to identify the end point of the network.
Prior to .NET 5.0, building and releasing Dockerfile for ASP.NET Core applications required capturing the entire .NET Core SDK. And has an ASP.NET Core image. With this release, the capture bytes of SDK images are reduced and the bytes captured for the ASP.NET Core image are largely removed.
Azure Active Directory authentication با Microsoft.Identity.WebASP.NET Core project templates are now integrated with Microsoft.Identity.Web to manage authentication with Azure Activity Directory (Azure AD). The Microsoft.Identity.Web package provides the following:
Better experience for authentication through Azure AD
Allow anonymous access to an endpoint
The AllowAnonymous method extension allows anonymous access to the endpoint:
JSON Console Logger
In addition to supporting custom formatters, we can also add a built-in JSON formatter that publishes custom JSON logs for the console. The following code shows how to switch from the default logger to JSON:
The log messages released for the console are in JSON format:
In this article, we tried to review some of the most important features added to ASP.NET Core 5.0. ASP.NET Core 5.0 In addition to the above, other good and new changes such as auto-refresh with dotnet watch, Startup class activation control, JSON method extension for HttpRequest and HttpResponse, application of attribute [Compare] on properties in Razor model Page and other items.