All about ASP.NET Core 2.1
This article highlights ASP.NET Core 2.1’s new features and concepts.
ASP.NET Core is the new version of ASP.NET and contains the most significant architectural overhaul of ASP.NET. This article will focus on the new features and concepts in the new ASP.NET.
What is ASP.NET Core?
ASP.NET Core 2.1, an open-source framework that allows you to build modern cloud-based web applications, is now available. It was designed from the ground up to provide a streamlined development framework for web applications that can be deployed to the cloud or to your local servers. It was redesigned to make ASP.NET more efficient, modular (so that you can add features to your application), cross-platform (so that you can easily create and run your app on Windows or Mac), and cloud optimized (so that you can deploy and debug your apps over the internet).
Here’s a list of core changes in ASP.NET Core 2.1
Razor Pages improvements
We have made many improvements to Razor Pages in 2.1 to make them even more productive.
Razor Pages in a particular area
Areas allow you to break down large MVC apps into smaller functional groups with their own controllers and views. We have added Razor Pages support to areas in 2.1 so that each area can have its own pages directory.
Support for /Pages/Shared
Razor Pages in 2.1 will return to finding Razor assets like layouts and partials within /[pages root]/Shared, before returning to /Views/Shared.
Web API improvements
ASP.NET Core provides a single framework that allows you to build both Web UIs and Web APIs. We have made many improvements to the framework for building WebAPIs in 2.1.
READ ALSO:Top 10 Highest-Paying Certs
Improved input processing
We want to make invalid input more predictable and automatic. We’re going to:
Make a programming model that doesn’t call your action code when a request is rejected. (See “Enhanced Web API controller conventions”) below.
Increase the fidelity of error messages when the request body fails or the JSON is invalid
Allow validation attributes to be placed directly on action parameters
OpenAPI specification support improved
We want to embrace OpenAPI (previously known as “Swagger”) and make Web APIs created with ASP.NET Core more descriptive. To get a reasonable OpenAPI spec for ASP.NET Core, you need a lot more “attribute soup”. We will introduce an opinionated layer which infers possible responses based upon what you’re most likely to have done with your actions. Attributes still win, if you want to be explicit.
ActionResult and Enhanced Web API controller conventions
As a way to opt in to Web API specific conventions or behaviors, use the [ApiController] attribute These behaviors include:
When validation errors occur, an automatic response is sent with a 400
Infer smarter defaults when action parameters are being defined: [FromBody] if complex types, [FromRoute] if otherwise [FromQuery]
Requires attribute routing. Actions are not accessible by convention based routes
WebHooks allow you to send event notifications over the internet using lightweight HTTP patterns. WebHooks allow services to send event notifications via HTTP to registered subscribers. The following receivers are available for 2.1