Written by 14:38 ASP .NET CORE, Languages & Coding

Everything You Need to Know about ASP.NET Core 1.0.

The question is: “Microsoft ASP.NET vNext: evolution or revolution?”, the absolute answer is revolution. In this article, I will try to describe in detail the latest technology for creating web applications, namely – ASP.NET vNext, which initially had the official name ASP.NET 5 and later was renamed to ASP.NET Core 1.0. There will be another series devoted to the development of a real application with examples describing the practical use of this technology.

I will start by describing the history of ASP.NET development. Back in 1996, Microsoft proposed a technology – Active Server Pages (ASP) for creating web applications. The basic idea of an ASP application was something like this: a web page on a server contained some VBScript or JScript server-side scripts, and when the page was requested, the scripts were launched and executed, followed by the generation of HTML. It was a big step forward when compared to CGI.

With the release of Microsoft .NET Framework, in 2002, a completely new platform for developing web applications, ASP.NET, had been delivered. In 2003, it was updated to version ASP.NET 1.1. That was the beginning of ASP.NET, back then, a completely new technology that had plenty of advantages over ASP. In fact, that was a full-fledged framework for web application development.

Time passed by and ASP.NET had been developing along with .NET Framework – the major upgrade was released in 2005. The main new features were: themes, master pages, globalization, etc. The web developed rapidly, web pages became more interactive and richer, and the AJAX technology appeared.

In 2007, another major update, ASP.NET 3.5, was released. It was then that such powerful tools like ASP.NET AJAX, LINQ, Dynamic Data were supported. With the release of ASP.NET 3.5 SP1 in 2009, a new MVC-based approach for processing web page requests appeared. Now, there are two: Web Forms and MVC.

Simultaneously with the launch of .NET Framework 4, ASP.NET was updated to the fourth version. Another major platform update was released together with the release of ASP.NET 4.5. Such tools as Web API and SignalR appeared. With the release of Visual Studio 2013, a new concept appeared – “One ASP.NET”. All components of the platform were updated, and a new specification appeared – OWIN (Open Web Server Interface for .NET), which became the basis of ASP.NET vNext.

Last year, Microsoft released a candidate version of the fundamentally redesigned technology for developing web applications, which received the official name – ASP.NET 5. Among other things, there is a large number of updated and new technologies and products from Microsoft, the final versions of which will be released this year.

And now, let’s list the facts as they actually happened. I’ll start with the biggest and most important event — the update and improvement of .NET Framework. But first, let’s recall the course of .NET Framework development:

The .NET platform was introduced in 2002 and quickly gained popularity becoming one of the major modern software development tools. The main advantages of .NET platform over the predecessor (the COM technology) are flexibility and a simpler and more reliable programming model. The platform has been developed, new versions, libraries, and technologies have been released to satisfy all the new requirements of the fast-growing world of information technology.

Well, of course, Microsoft does not sit around idly and continues to improve .NET platform in order to keep up with the times. The platform released last year has been recently updated to version .NET Framework 4.6.2. So, what is the future of .NET? And the future is really interesting and promising.

As can be seen from the above drawing, there are basically two versions of .NET Framework. The first one is a logical continuation of the current version .NET 4.5.2, which is officially named .NET 4.6 (the updated versions: .NET Framework 4.6.1 – 4.6.2). The second one is now referred to as .NET Core 1.0 (previously known as .NET Core 5) and is a simplified version of the standard .NET Framework. The first one is self-explanatory, while the second one raises a lot of questions. The most important one is why we need it? To meet the growing needs of today’s digital world that is developing rapidly.

If you look at the .NET platform development scale provided above, we can see that the release cycle of the new versions covers a couple of years, or even more, which is a very long term at the current state of things. The situation needs to be changed for the better, the decision is .NET Core 1.0. The latter must satisfy the modern requirements for development, thereby new trends for promoting and developing the platform have been established: a rapid development cycle and community participation.

An independent organization .NET Foundation was established for these purposes. The organization will be involved in the development of .NET ecosystem. This link provides a list of all the current projects that will be developed under the supervision of the organization. That is, .NET platform becomes open. Full modularity – that’s one of the main features that I like the most. This is especially useful for web applications, and later I will tell you why.

The following drawing shows a general model of an application that will use the .NET Core platform. The modularity of .NET Core means that the framework will be delivered in parts through NuGet, making it possible to deliver the application together with the platform that will be isolated from the others. That is, there won’t be a common version of .NET for the entire computer.

More information about .NET 2015 and .NET Core is available on Channel 9. And what should we expect in the nearest future, what will happen to .NET tomorrow?

More information on the present and future of the platform is available in the dotnetConf 2016 reports. Now, let’s talk about ASP.NET Core. The image below demonstrates the general scheme of the platform.

As can be seen from the drawing, the key features of the new technology are that it is completely modular and cross-platform. Using the framework as a part of the deployment package, you will no longer encounter problems with the configuration of the hosting environment for an application. Each application will have its own independent version of the platform.

Almost the entire platform is written from scratch using manageable code. All the source code of the latest version of the web-based platform is open and available on GitHub. The ASP.NET MVC and Web API technologies are combined into one, and Web Forms are no longer used in version ASP.NET Core.

The new version of ASP.NET on Windows will run using one of the two versions of .NET Framework: .NET 4.6 and .NET Core 1.0, and only .NET Core will be used on Linux and Mac OS X. More information on ASP.NET Core is available on Channel 9 What’s New with ASP.NET 5″, the same course is available on the Microsoft Virtual Academy website (ASP.NET 5 was renamed to ASP.NET Core 1.0). Also, I recommend you to review the course “ASP.NET Core 1.0 Fundamentals” from Pluralsight. As for myself, I learned a lot of interesting and useful things from the report “ASP.NET vNext: What it means to you and what it means to Microsoft“, which I reviewed several times.

Now, let’s explore the features offered by the latest version of .NET Framework in terms of web development.

We will see what else can be done with the latest .Net platform. To see what is available at the moment, we can just open Visual Studio 2015 Update 3 with the latest version of ASP.NET and Web Tools (VS2015Tools.Preview2.0.1).

The image above shows that there are two categories of templates for ASP.NET applications, for the recent version ASP.NET Core 1.0 and the updated ASP.NET 4.5.1 that was officially named ASP.NET 4.6. There were lots of discussions regarding the last digit in the version. The choice was between 4.5.3 and 4.6. Consequently, the latter was selected on the basis of the major opinion.

A developer that has experience working with previous versions of the platform might think in the first place that the given template was designed for compatibility and maintenance of previous versions of the technology. At least, it has always been like that, let’s recall Visual Studio 2010/2012/2013. Is it really so? Partially, yes in some ways. If we keep only content for the web, we will get something like this:

Therefore, today Microsoft offers two technologies for web app development: ASP.NET 4.6 and ASP.NET Core 1.0. A detailed description of the recent version, ASP.NET Core, will be provided in the subsequent articles. In this article, let’s compare them with each other.

Firstly, let’s see what the updated ASP.NET 4.5.1 can offer. Let’s return back to 2013 when the first release of Visual Studio 2013 took place. If some of you may remember, back then we haven’t received anything new in terms of global changes. Yes, there was a so-called idea of combining Web Forms, MVC, and Web API that got the name of “One ASP.NET” but it ran a little bit late (to be more specific, it could have appeared earlier, but it hasn’t).

Of course, the technologies and libraries have been updated, but there was nothing revolutionary, except OWIN and its implementation called Katana. But what did we really get with OWIN in ASP.NET 4.5.1? Absolutely nothing useful. The only thing – the pipeline got even more complicated, though it was complicated before. Admit that complication is not reasonable if it does not make any good.

The image below shows the schema of pipelines: a standard ASP.NET/IIS pipeline is on the left, the same pipeline is in the middle but with the OWIN specification, if fact, there are two of them, both the right one – a pipeline without IIS and ASP.NET. In particular, the image shows how simple and lightweight is the OWIN pipeline without IIS (click here to open a high-resolution image).

But why did the OWIN specification turn out to be useless and did not bring anything new and essential? Well, it’s because its implementation was far from perfect, it was the beginning of the end of the IIS monopoly for ASP. NET. Implementation of this specification on IIS was not useful, and its external usage is problematic. Why problematic? Because no matter how good the idea is, it must be implemented and properly tested.

Of course, there is a possibility to host an application outside IIS, but using a personal server or host (Self-Host) of a conventional console application level is irrational for serious applications. We may be somewhat unsatisfied with IIS, but all the existing administration means (management, diagnostics, logging, etc.) of the server and the experience (bundle of knowledge) cannot be disregarded.

Still, the further development of the OWIN specification provided the basis for ASP.NET Core. Despite that, ASP.NET 4.5.1 was updated and got the new version, ASP.NET 4.6. It ought to be mentioned that ASP.NET 4.6 involves the following variety of technologies: Web Forms, MVC 5.x, Web API 2.x, and SignalR 2.x. And this time, Microsoft did not stop supporting the “outdated” technology, but on the contrary, they added lots of interesting and useful things. Let’s take a look at the most important ones.

Support for the HTTP/2 protocol

The new version of the HTTP protocol was added to ASP.NET and .NET Framework 4.6. To use HTTP/2 with ASP.NET, an application should run on Windows 10 or Windows Server 2016; the OS number is not that important, whereas the IIS version is essential – IIS 10 or higher is required.

At the time of writing this post, support for HTTP/2 has not been added to ASP.NET Core yet, but it will be for sure.

HTTP/2 is a new version of the HTTP protocol, that provides more effective communication (fewer round-trip cycles between client and server) and delay minimization during loading of a web page for users. HTTP/2 provides a maximum advantage for web pages (in comparison with services) since it optimizes the request of various artifacts during one operation. All work is done by a browser and web server (IIS in Windows). There is no need to shift the burden on users. Most of the browsers (new versions) support HTTP/2, and it’s likely that users will be able to take advantage of the HTTP/2 protocol if it is supported by a server. For more information on the new protocol, please refer to this link at Channel 9. In my opinion, it is an essential update for ASP.NET 4.6.

Support for .NET Compiler Platform (“Roslyn”) in ASP.NET.

As for me, this is another great improvement. In short, I’d like to mention the most important improvement that we have when using Roslyn – compilation speed. In addition, there are new possibilities of programming languages, though I consider them to be of little use so far. To get more information on this issue, you can refer to this article.

Other improvements and updates in ASP.NET 4.6.

This paragraph lists less important but still quite useful improvements and updates. MVC 5 and Web API2 were updated to version 5.2.3, minor improvements and bug fixes were made. Asynchronous Model Binding was added in Web Forms, controls were updated to support Entity Framework 6, the Ajax Control Toolkit library was updated. The entire list of updates can be found in this article.

Also, I would like to mention one more improvement – a new 64-bit JIT compiler, that is not directly related to the ASP.NET 4.6 platform, but it is used by it. NET Framework 4.6 features a new version of the JIT compiler that has much higher performance than the existing 64-bit JIT compiler.

So, we may conclude that the number of changes and improvements is quite impressive, which makes the ASP.NET 4.6 platform quite up-to-date. And of course, there will be more improvements in the future.

What about the brand-new version of ASP.NET Core?

Here, I will briefly list the most notable features that will be described in more detail in the subsequent articles.

  • Much faster and more lightweight execution environment.
  • The possibility of hosting an application anywhere and anyhow you like – there is no strict tie-in to IIS anymore (though this possibility was introduced a bit earlier, but it was not that convenient and complete, as I noted above).
  • Full modularity owing to key changes and .Net Core.

As for the cross-platform feature (possibility of hosting applications outside Windows, in this case, these are Linux and Mac OS), no matter how widely it is advertised, I do not consider it a key change, though I may be wrong.

I can hardly imagine a developer who uses everything from Microsoft shifting from ASP.NET to another OS. However, it is possible that developers who use other platforms will use ASP.NET Core outside Windows.

Of course, there are other alternate and worthy technologies there. The possibility of configuration and deployment has been much simplified, but shifting to JSON is hard and not convenient for developers who have been working with XML for a long time. Today, JavaScript libraries and platforms widely use the JSON-based approach. It is much more convenient to have something like this on the server side.

One stack for both, user interface (Web UI) and API is more reasonable in comparison with two stacks. However, back then, the task was to make a separate technology for the creation of the HTTP services, which could be developed separately from ASP.NET/IIS, but this ambition apparently failed. Also, new means that simplify the process of application diagnostics were added.

All mentioned above makes applications on ASP.NET Core more cloud-friendly (Cloud Optimized ASP.NET), and as we know, cloud technologies now play a big part and will play a yet bigger part in the future. And finally, I’d like to point out that all the mentioned changes appeared owing to the fact that the platform was rewritten almost from scratch taking into account the existing experience and modern requirements.

So, we have lots of new features and improvements. But what do all of us who use this platform get with this new technology? All my experience suggests that to build a “correct” application, technology takes a back seat, and, in most cases, does not play the leading part. That is, if an application does not solve (or solves poorly) the intended problems, even the most advanced technology will not help to fix the situation.

Five years ago, the so-called “front-end” developers (under this term I mean not a layout designer, but a developer who is an expert in JavaScript, different libraries, and JavaScript-based technologies) were not taken seriously. Now the situation is completely different. Writing JavaScript code is no easier, and sometimes even harder. JavaScipt is a ‘soul’ of the web today, and you can’t disregard it.

Regardless of whether we want it or not, the approach when HTML was generated on a server with the help of the server technologies becomes less and less popular, and there’s a reason for this. A web application today is something bigger than it used to be 10 years ago. First of all, it brings complexity that becomes unreasonably high if we use server technologies, such as ASP.NET Web Form or ASP.NET MVC for implementation of the complex and interactive application logic on a client instead of, let’s say, JavaScript. Until today, Visual Studio couldn’t offer anything that, for instance, WebStorm has in terms of ‘front-end’ development (developers who work with WebStorm will understand me). And using ASP.NET exclusively as a server layer is not always reasonable, if we take alternate technologies into account.

With ASP.NETCore, the situation changes. Though, the functionality for SPA in comparison with WebStorm, in my opinion, remains limited. Perhaps, I’m too critical and I could get away with the existing capabilities of Visual Studio, but it’s terribly inconvenient. For instance, there were no built-in means for working with Gulp or Grunt before Visual Studio 2015 and ASP.NET Core. Therefore, I’m glad about lots of options and features in ASP.NET Core.

Conclusion

So, let us be pragmatic, and having two technologies for web development at hand raises the following question:

What should we do, what is our choice?

In this case, the choice is anything but simple.

If you have a desktop ASP.NET Web Forms application and lots of available resources (funds), migrate to ASP.NET Core.

If your resources are limited, I recommend making the gradual migration to ASP.NET 4.6. With the ‘One ASP.NET’ idea, you can do it step by step: leave old code here and MVC there.

As for the parts where productivity is critical on both, client and server – use a single page approach (SPA), for instance, by means of AngularJS.

My developers and I did something of the kind, I have experience in migrating corporate web portals from ASP.NET 3.5 to ASP.NET 4.6. To tell the truth, it is not that simple as it seemed: there were too many pitfalls that were partially caused by the code quality. If your code does not meet your needs, you should think of it, not about the technology or platform.

If you have an ASP.NET MVC application, it is worth switching to ASP.NET Core in the following two cases:

  • if your application has problems with productivity (and you’ve done everything about it, and there is nothing left to optimize),
  • or, if you have lots of money spare time.

Otherwise, you need to improve your code.

There are cases when the code is tightly bound to System.Web.dll and IIS, and this is a good reason for not touching anything. And here is the last case: if ASP.NET is used solely for web services, for instance, in the case with Web API. Examples are single-page applications (SPA) or distributed applications that may have no relation to HTML. In such a case, switching to a new version is much easier.

Still, if you are satisfied with everything, there is no need to switch to ASP.NET. In most cases, it is enough to update .NET Framework to version 4.6. I know applications and people that still use traditional ASP and are happy with it. If you are not satisfied with the productivity of Web API and IIS, it is a good reason for updating to ASP.NET Core.

Now it is time to answer the main question, which is: What is our choice, ASP.NET 4.x or ASP.NET Core? There is no absolute answer to this question, it depends. It is your choice, and you should remember that the future belongs to ASP.NET Core and it will come sooner or later.

Tags: , Last modified: September 24, 2021
Close