April 4, 2017 enqos

Key things you need to know about ASP.NET CORE

Introduction

After all the years of ASP.NET, Web Forms, and MVC, why did Microsoft take a leap towards the new ASP.NET Core 1.0, is the question that comes to anyone who takes a look at first? If the usage of Microsoft technologies is considered in the market, Windows desktop apps are reducing day by day and in mobile technologies, windows phones are in nowhere in comparison to android and iOS phones available in the market. Coming to the web platform, the only remaining Microsoft technology is ASP.NET and it is competing with Node.js, Ruby, PHP etc most of which are open sourced and has very good developer base.

Getting started with web development with ASP.NET is time-consuming and heavy. Visual studio has to be installed and the whole process to build and deploy the web application to the servers take more time compared to the open source web technologies. On top of this, to develop an asp.net web application, we need to use windows operating system and the web application can only be deployed on a windows machine having IIS. These were the major factors that forced Microsoft to come up with a better, lighter, faster and completely open sourced and platform independent technology.

The ASP.NET core has multiple benefits like lightweight, ability to use Gulp, Bower, and Yeoman, can be developed using a variety of text editors like Visual Studio Code, Atom, Sublime Text, optimized CLR and so on. Few main benefits are discussed below.

Benefits of .NET Core

Platform Independent

To overcome the problems faced by developers to deploy to a Linux machine or a Mac machine, ASP.NET Core has been made platform independent. The developed application can be deployed on any operating system – windows, mac or Linux. The framework used to run the application is packaged with the deployable files so that it does not depend on the framework installed in the system to run. The web server on which the application will be hosted is Kestrel. This server can also be used when developing using Visual Studio to run the application. This server enables the developers to save and refresh to get the updates than to compile and debug again. To enable the developers to use any operating system to develop the asp.net applications, Microsoft has launched the Visual Studio Code, which is a visual studio code that has many of the functions offered in Visual Studio but is extremely light weight.

Middleware and Dependency Injection

Dependency injection is vital when developing big applications to maintain loose coupling between classes and to provide separation and concerns and most importantly the ability to unit test easily. ASP.NET Core has integrated the dependency injection into the framework. Using many third party tools, the unit testing can be done effectively.

Middlewares completely changed the way the request and response are served. Instead of having a predefined flow of events and actions based on the events during the cycle, the developers are given the complete discretion to create middlewares that handle the requests. Middlewares can be stacked one top of the other and so when a middleware forwards the request to the next one on the stack, it sees the request. If the first middleware sends the response to the request, then others don’t see the request at all.

OpenSource

Another big step by Microsoft is to make the ASP.NET Core open source. The entire framework sources and packages can be found on the github site and the participation of developers for the major features of the ASP.NET, tools, middlewares and third-party applications that support the development is getting larger by the day. Since its open source, the developer community is also getting better and the documentation is constantly being updated so beginners don’t have to spend time searching where to start.

Simplified Structure and Single Framework

The structure of an ASP.NET web application is completely simplified with no App_Data and App_Start. The Global.asax has been replaced by the Startup.cs, where all the middleware components will be registered and the start point of the application. The app settings in web.config is also moved to a separate file.

In previous versions of ASP.NET, to have both MVC and API, we need to have two types of projects to accomplish it. In the latest ASP.NET Core, we have just one namespace under which both MVC and Web API classes are maintained which will cause very less confusion for the developer.

Disadvantages of .NET Core

Documentation and Tools

The documentation of the ASP.NET Core is not great when compared to other development technologies. It is being updated very frequently and any gaps present are being filled actively by Microsoft and other contributors for the project. Still, when trying to develop an application and trying to find the root cause for the exception could be a little tricky because there is a constant update in the documentation and in the framework. The solution that is given might not exactly work because of the changes in the framework. Both documentation and tooling and getting better day by day and should be able to catch up with the needs of the developers soon enough.

Is .NET Core suitable for you?

Choosing between ASP.NET Core and ASP.NET framework is totally a decision that depends on the purpose.

Use ASP.NET Core when

  • You want to try out the new features in ASP.Net core and the application is not an enterprise application that has various security features.
  •  You have developers working on Mac and Linux to develop the application and also have an intent to deploy it in the Mac and Linux machines.
  • You want high-performance applications. The ASP.NET Core applications are extremely fast when compared to the ASP.NET applications.
  • You want to work with containers like Docker for the deployment of the applications.

Use ASP.NET when

  • You want to use the support and documentation available on the internet. This is still being developed in ASP.NET Core so getting a problem resolved is not easy there.
  • You want to develop an enterprise application that has all the security loopholes and is a vast application that uses existing tools and third party apps that are not ported to ASP.NET Core yet.

To install the ASP.NET Core, use the link https://www.microsoft.com/net/core and download the tools for ASP.NET Core. It is also necessary to install the SDK before you can start using it. You can find the SDK in the link https://www.microsoft.com/net/download/core. The steps given on the Microsoft site is self-explanatory and easy to install. You can get the Visual Studio Code from https://code.visualstudio.com/download.

Conclusion

The features that are packed inside ASP.NET Core is very useful and the fact that it is open source and platform independent attracts many developers to start using it. It is blazingly fast and very simple too. At this time with growing developer base it might be better to get hands on the future technology by either extending a small portion of an existing application or trying to build from scratch a small project that can exactly assess the benefits and pitfalls of ASP.NET Core.


About the author:

Vignesh Vaidyanathan is a Senior Developer at Enqos who loves to learn the latest technologies in the industry. He is a hardcore Microsoft developer, developing applications with React, hosting them in Amazon Web Services and uses GSuite to manage his daily tasks. His routine is dribbling around complex logics, taking free kicks at new technologies, scoring goals past performance bottlenecks and lifting the product trophy. As you might have got it, he is a geeky footballer.

Tagged: , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *

Shares