Microsoft has released the first version of ASP.NET together with .NET 1.0 in 2002. That version was focused on so called “Web Forms”. The main idea was to give the web-developer the same look and feel as he would have had while working with a usual windows application. So he got the designer file for a user interface, on which he could drag & drop controls, having code-behind executing logic underneath on the server side.
It appeared that porting windows application development experience into the web may be not the best idea. In 2009 Microsoft released the first version of ASP.NET MVC. That one gave developers a lot of flexibility, decoupling user interface parts from business logic and data access layer.
It was a great step forward! Microsoft invested a lot and made sure that web development was becoming much more fun! Until developers realized that ASP.NET MVC is strongly coupled to the System.Web assembly which in the end limits your infrastructure to only one possible server – IIS and in consequence – Windows.
Continuing with presence
Microsoft released quite many versions of ASP.NET. It is important to remember that the latest version of ASP.NET was named ASP.NET 4.6. In January 2016 the whole development world got the news that Microsoft just released new ASP.NET 5.0! And then we got into naming hell… (by the way which of you, developers, don’t have a problem with naming once in a while?). Few weeks later they announced that ASP.NET 5.0 is DEAD! What they really released is:
And eventually we’re getting to the topic of this article! (and by the way the latest release is already the ASP.NET Core 2.0!) First of all I want to warn you that this is not an ASP.NET Core walkthrough, nor the full specification of all the new features. I just want to give you a taste of a completely new paradigm. I will focus a bit more on the motivation for all the changes as well as a brief description of what in my mind is most important for you as the developer!
Motivation behind the ASP.NET revolution
- Cross-platform ASP.NET applications
Over the years Microsoft was really focused on delivering against only one execution environment, which was Windows. Current releases show a complete mind shift. Microsoft released .NET Core which can be run more or less on any operating system. ASP.NET Core was a natural consequence of allowing developers to execute on top of that. Currently developers have a choice while they set up a new project to either run ASP.NET Core on .NET Core, or use full standard .NET Framework ensuring full backward compatibility!
- Open source and community focused
If I would bet few years ago that Microsoft will release a framework that could work on Linux or Mac you would probably say that I‘m either drunk or a dreamer. If I would add that this will be open source…. That is really happening! Whole ASP.NET Core is fully open source and available on GitHub: https://github.com/aspnet/home
That gives the developers not only a great way to deep dive into the code and understand how the pieces are working together, but also let them contribute. Until now there were quite a lot of commits delivered by the community!
- Rapid development cycle and lightweight dependencies system
As you can see from the ASP.NET history diagram, the development process was quite heavy and long. What is more, the solution based on the old ASP.NET was really complex when it came to the framework dependencies. That’s totally changed now. All dependencies you need at startup are:
And any other required parts are distributed as nugget packages which are easy to reference, update, and maintain! And clearly it is much easier to release new versions to the market.
What is really new in ASP.NET Core
- Completely new Request/Response pipeline
ASP.NET Core introduces a totally new pipeline of handling request / response flow. Microsoft decided to give the developers full control on what stages are executed during the pipeline. Speaking more about code, the pipeline mechanism is simply a set of request delegates executed one after another:
Any delegate can actually block the execution and stop passing it further to the next delegate. So from now it is entirely up to you (the developer) to decide how the requests / responses will be handled!
- New motion of configuration
In the previous versions of ASP.NET you really had only one official way of configuring your application. You had to use a Web.Config file, which was a quite heavy xml structure. It got completely changed now. At the application startup you can define your source of configuration, choosing either json, xml, environment variables, or others. It really is as simple as that:
And so the sample configuration can look like:
- Dependency injection all the way
If you ever used the MVC ASP.NET you most probably succeeded with decoupling the view, model, and controller. But after some time when you looked at some of the actions of the controller you noticed that it is actually really complex and obviously not limited to a single responsibility. Now Microsoft is giving the developer full Dependency Injection framework. You configure the abstraction’s implementation in the Startup.cs file:
And it is available through the full stack, beginning with controllers:
Ending on the views where instance of any service can be injected:
We already got ASP.NET Core 2.0!
Some could say that ASP.NET Core is really the playground with not everything settled down and ready. But in July of 2017 we already got the second release of it. It is again adding quite a lot of improvements and new bits, including:
- Razor Pages
- Runtime Store
- Targeting of .NET Standard 2.0
- Single Page Application Templates
- Updates for: logging, configuration, and authentication
Stay tuned as we will definitely cover most of those goods in further posts!!