Why do you need to migrate your code to ASP. NET Core 2.0?

Source: Internet
Author: User
Tags app service webhost

650) this.width=650; "Src=" http://images2017.cnblogs.com/blog/139239/201709/139239-20170926091208839-698849372. PNG "style=" border:0px; "/>

With the release of. NET Core 2.0, the. NET open source cross-platform ushered in a new era. Developers can choose to develop their own. NET Core 2.0 projects using command line, personal preference Text editor, Visual Studio 2017 15.3, and Visual Studio Code. At the same time, the Microsoft. NET Development Tools group announced the release of ASP. NET Core 2.0, and this version is compatible with the. It is believed that the most discussed issue for developers in the technical community at the moment is: Should the code be migrated to ASP. NET Core 2.0? ”

The answer is yes.

Let's look at the benefits of migrating code to ASP. NET Core 2.0.

Performance

Performance improvement is the most significant change that ASP. NET Core 2.0 brings.

With the advent of new technologies and language enhancements in ASP. NET Core 2.0, the code is automatically optimized at compile time.

The good thing about this change is that individuals no longer need to change the code. The compiler optimizes the code when it is recompiled with the new language enhancements.

Techempower found that in more than 230 frameworks that use WEB framework benchmarks, ASP. NET Core has made tremendous progress in performance.

New Coding Paradigm

The release of the new version of ASP. NET Core introduces a new coding paradigm. The new coding paradigm makes page-based design and coding much simpler and easier than model-view-controller structures. Using Razor pages as the page structure of the first page allows developers to focus more on the user interface.

If you are familiar with configuring the ASP. NET Core Startup class for MVC, you can add the following code to the Startup class:

public class startup{public void Configureservices (iservicecollection services) {//Includes support for Ra        Zor Pages and controllers. Services.    Addmvc (); } public void Configure (Iapplicationbuilder app) {app.    Usemvc (); }}

The ADDMVC and Usemvc in the Startup class are configured to invoke and activate the "Razor Pages" feature.

The new Pagemodel object enables you to build more complex structures. Pagemodel is a concept of the MVVM schema that allows developers to execute methods and bind properties to the content of the page being rendered.

Template Enhancements

The template that came with ASP. NET Core has been enhanced to include not only Web applications built using the MVC pattern, but also the Razor Pages Web Application template, as well as a series of templates to build a single-page application (SPA) for the browser. These SPA templates use the JavaScript service feature to embed NodeJS into ASP. NET Core on the server, and the JavaScript server-side application as the. NET build process is compiled.

650) this.width=650; "Src=" http://images2017.cnblogs.com/blog/139239/201709/139239-20170926093844370-1113583176. PNG "width=" 781 "height=" 509 "style=" border:0px; "/>

DbContext Pooling

Many ASP. NET Core applications can now be configured to use pre-created instances pools to gain performance gains by registering their DbContext-type services to avoid creating new instances for each request.

You can enable DbContext pooling by adding the following code to the startup/Configuration service.

Services. Adddbcontextpool < Bloggingcontext > (options and Options. Usesqlserver (connectionString));

monitoring and configuration improvements

When running on Azure App Service, ASP. NET Core 2.0 not only requires no modifications, but also provides integration features, as well as access to performance analysis, error reporting, and diagnostic results provided by Azure application Insights. In Visual Studio 2017, when you right-click Project and select Add–application Insights Telemetry, the application starts collecting data. Finally, you can view the performance of your application directly in Visual Studio 2017, and also include all log messages.

650) this.width=650; "Src=" http://images2017.cnblogs.com/blog/139239/201709/139239-20170926093943214-589046393. PNG "width=" 791 "height=" 681 "style=" border:0px; "/>

Razor Update

The Razor engine has been updated and is now ready to use the new Roslyn compiler, including support for c#7.1 features such as default expressions, inferred tuple names and generic pattern matching. To use the c#7.1 feature in your project, you need to add the following properties to the project file and then reload the solution:

<LangVersion>latest</LangVersion>

simplifies host configuration

The host configuration has been greatly simplified. The default ASP. NET Core template contains a new webhost.createdefaultbuilder that automatically assigns a Kestrel server. If the Kestrel server is available, it will run on IIS and configure standard console logging. The Program.cs file has been simplified to the following:

public class program{public static void Main (string[] args) {buildwebhost (args).    Run (); } public static Iwebhost Buildwebhost (string[] args) = Webhost.createdefaultbuilder (args). Usestartup<startup> (). Build ();}

Summary

ASP. NET Core 2.0 is not only a huge performance boost, but this version of the update also provides a new way to write applications, while simplifying the process of managing applications. These all make up the reason that you migrated your code to ASP. NET Core 2.0.

Reference article:

Https://dzone.com/articles/4-benefits-of-migrating-to-aspnet-core-20

https://blogs.msdn.microsoft.com/webdev/2017/08/14/announcing-asp-net-core-2-0/

reproduced please specify from: Grape City Control


about Grape City

Grape City is the global control industry leader, the world's leading enterprise application customization tools, enterprise reporting and business intelligence solutions provider, for more than 75% of the world's Fortune 500 enterprises.

This article is from the "Grape City Control Technology Team Blog" blog, be sure to keep this source http://powertoolsteam.blog.51cto.com/2369428/1968697

Why do you need to migrate your code to ASP. NET Core 2.0?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.