Join Jess Chadwick for an in-depth discussion in this video Understanding ASP.NET 5 for ASP.NET developers, part of Up and Running with ASP.NET 5.
- View Offline
- In a previous video, I gave you a very high level overview of the components that are involved in creating and running an ASP.NET 5 application, and that information is relevant to you regardless of whether you've been using the ASP.NET framework for years or just getting started with ASP.NET. However, it's important to note that version five of the ASP.NET framework has been completely rewritten from the ground up and this means a lot has changed from previous versions. On the other hand, a lot has stayed very much the same as well. In this video, I'm going to run through a high level comparison between ASP.NET 5 and previous versions of the ASP.NET framework so that it's very clear what aspects of the previous versions carry over into this version and which concepts are brand new to ASP.NET 5.
So if you have been using the framework for a while and feel like you know it pretty well, this video is for you as it will help you get the most out of this course by identifying the areas of the framework and the videos in this course that you're going to want to focus on and which parts you can skim through since those areas of the framework haven't changed much. On the other hand, if you don't have much or any experience with previous versions of ASP.NET, then this video won't be much use to you so you can probably just skip it and jump right into the next chapter to begin the course.
As I mentioned in the beginning, the most important aspect of ASP.NET 5 is that it has been completely rewritten which is a pretty significant undertaking no matter what the code base. Why did Microsoft take such a drastic approach? Well, here's a summary of all the improvements that have come as a result. In short the ASP.NET framework is roughly 15 years old and it accrued a lot of code and features over the years not to mention the web development world has also changed a lot over those 15 years meaning that some of the features that existed in the framework have grown obsolete or inefficient and now there are new and better ways of developing web applications.
Let's run through this list. Previous versions of the .NET framework were very tightly coupled to the Windows operating system, and previous versions of the ASP.NET framework were tightly coupled to the IIS web server running on Windows. However recent years have seen an explosion in web servers and IIS is not the only web hosting environment available. There are a number of lighter weight solutions that developers might like to take advantage of including self-hosting or not requiring a dedicated web server at all. So rewriting the framework from the ground up takes care of many things all at once.
Most importantly, it decouples the ASP.NET framework and the .NET framework as a whole from IIS and even Windows itself, allowing .NET developers to embrace other operating systems and web hosting environments such as Linux or even the emerging technology of Docker containers. It also allows Microsoft to take a more modular approach allowing developers to include only the parts of the framework that they need. A nice side effect of this modular approach is that Microsoft is able to simply not re-implement some features, enabling them to eliminate parts of the framework that may no longer be relevant or as efficient as they once were.
In other words, Microsoft was able to write the next generation web application development framework while still making it look almost exactly like the framework that millions of developers are already familiar with. And just like the old framework, this new framework consists of two main parts, the ASP.NET web development framework and, the Core common framework that it runs on top of, .NET Core. You're already aware of what ASP.NET is so what is .NET Core? .NET Core is a lightweight, cross-platform version of the full .NET framework that you've been used to using all of these years.
In other words, all of the APIs that you know and love such as the the System.Xml and System.IO namespaces are all still available but they've been given a facelift. Some of their methods or method overloads may be missing and some new cross-platform abstractions may have been introduced but overall it's pretty much the same. Perhaps the biggest difference between the full .NET framework and the .NET Core is that .NET Core is not centrally installed on the machine but rather copied locally with each application, and it sits right next to the other third party libraries that applications may depend on as well as the application code itself.
In other words, when you deploy an ASP.NET 5 application, you're also deploying the parts of a .NET Core framework that it depends on as well. That means that it's possible for all of the various applications hosted on a single server to be running different versions of the .NET Core framework, and you can completely control when or even if individual applications get upgraded. This is the type of approach that is required for applications hosted in the Cloud to remain truly isolated from one another.
Since this course is specifically about building ASP.NET 5 applications, I will not be going very deep into the .NET Core framework. But the real reason I won't go into the details of the .NET Core framework in this course is because it simply doesn't matter. All of the ASP.NET 5 features all show and the code I'll write in this course will work great in either the Core or the full versions of the .NET framework. The one significant way that this will impact you as a developer familiar with previous versions of ASP.NET is that in order to achieve cross-platform support, the entire System.Web namespace has been removed and replaced.
That includes everything, all the way down to the fundamental interfaces such as HTTP modules and handlers. This reflects the fact that the request processing pipeline itself has changed. Rather than modules and handlers, we now have the new concept of a middleware pipeline, which I'll explain in the Basics chapter. Also the Web API framework classes are completely gone. It's all part of ASP.NET MVC now. But I'll get into that in later chapters too. Though this might sound shocking, it's really less earth-shattering than it seems.
You see the mindset that the Microsoft team stuck to when it implemented everything was something they called Concept Compatibility. For example, applications built with previous version of ASP.NET may have depended heavily on the System.Web.HttpContext class to gain access to things like the current request, the current user, or the response that was going to be returned. Well, ASP.NET 5 still has an HttpContext class and that class even has properties such as request, response, and user.
In other words, if you want to get the user name for the current user, you're going to access the HttpContext.User.Identity.Name property to find it. It's just that none of those classes are going to be the same System.Web classes that they used to be and these new classes may not have implemented all of the methods and properties that you've used in some more advanced scenarios. Now ASP.NET as a web development platform has always had a number of competitors.
Developers typically embrace anything that it can improve this workflow. Microsoft has attacked this on two fronts. The first is that ASP.NET applications don't require compilation. That is, they are compiled on the fly and whenever a change is made to code that would have previously required a full recompilation of the entire app, the new dynamic compiler is smart enough to update only the parts of the compiled code that have changed, avoiding the need to recompile the entire application again. As a developer who has worked with ASP.NET in the past, I'm sure you can relate to how much time this can add up to over the course of a day.
If you've ever looked at the build process of a Node.js application in Envy, then it's time to stop being so jealous. Now you can have the same exact process in your ASP.NET application. As you might expect, the addition of the .NET Core framework and the new way of handling client side artifacts also changes the way in which you deploy and configure your applications, though I'll cover the new deployment concerns in the last chapter. In the spirit of embracing evolving development practices and modern web development, Microsoft also introduces two new APIs that are at the core of the new runtime, configuration and dependency injection.
The new configuration API does away with traditional .NET application configuration techniques such as Web.config, App.config, and even Machine.config and instead leaves it entirely up to the developer to explicitly import their own settings in whatever way they see fit. While that sounds rather open ended, the configuration API also offers support for popular configuration techniques such as JSON and custom XML files, and even environment variables that are popular in the Linux world.
And last but not least, Microsoft has built the new .NET Core and ASP.NET frameworks to support true dependency injection at every level in the application stack. That means that you have full control over which parts of the framework are included, up to and including the ability to configure them, wrap your own code around them, or even completely replace them if you like. Of course, the framework encourages you to apply dependency injection techniques to your own applications as well. If your team is already leveraging dependency injection with a particular inversion of control framework such as Autofac or Inject, that's okay too.
The new .NET Core dependency injection framework is completely pluggable, allowing you to replace Microsoft's implementation with any other implementation and, if you look, I'll bet that you find your favorite IoC container already has a version that's compatible with .NET Core. So everything I just explained is what's new and different in ASP.NET 5. Now let's talk about this course. I've made this course to be approachable by anyone with the basic knowledge of the .NET framework which includes folks who have never used any version of ASP.NET prior to this one.
That means that if you're already familiar with previous versions of ASP.NET and ASP.NET MVC then you'll already know a bunch of the stuff I'm about to show you. If that describes you, then here's how to get the most out of this course. Even if you're an experienced developer, you're definitely going to want to watch at least the first few videos of the Basics chapter where I outline the new idea of middleware and how to add references to external libraries. This will help you get acquainted with the process of working with the .NET Core libraries as well as the new concept of the middleware pipeline that will be so crucial to understand going forward.
I also encourage you to watch the last two videos of the Basics chapter which introduced two new web development tools. But ASP.NET 5 does not require you to use these tools to build your applications, so you can feel free to skip these chapters in the beginning and come back to them whenever you like. If you're already familiar with previous versions of ASP.NET MVC, then almost none of the code that I'll be showing in the ASP.NET MVC 6 chapter is going to be new to you. The major exception to that is the initial package installation and a few lines of configuration code that I'll show in the beginning of each video.
If you find yourself not really learning anything new in each of these videos, feel free to skip on to the next video. There are two big exceptions to this though. ASP.NET MVC 6 has two brand new and powerful features called tag helpers and view components, so you're definitely going to want check out the tag helpers video in the Working with Data chapter as well as the Reusing Application Features with View Components video in the Maintainability and Reusability chapter. The same goes for the web API chapter.
Web API controllers and ASP.NET MVC controllers are now the same thing, and if you already know ASP.NET MVC, feel free to skip to the next video if you don't feel like you're seeing new APIs or concepts. If you're interested in the new configuration and dependency injection APIs and the new membership system you're definitely going to want to check out the entire maintainability and reusability chapter and the videos on the new identity services API in the Security chapter. Not only are the concepts in these videos new to ASP.NET 5, they're also incredibly useful and powerful.
And finally, the mechanics of deploying your application have changed a bit, so you're going to want to watch at least the first video of the Deployment chapter in which I give an overview of what you're going to need to know. Then you'll want to watch the IIS and Azure deployment videos but only if you plan to deploy to those hosting environments. Now that I've given you a high level overview of the differences between the previous version of ASP.NET and the changes that ASP.NET 5 brings to the table, let's continue on with the rest of the course by moving on to the next video where I'll expand upon all of these concepts and show you how to make the most of ASP.NET 5.
- Understanding ASP.NET 5's new request processing pipeline
- Downloading client-side libraries using Grunt and Bower in Visual Studio
- Adding ASP.NET MVC 6 to your application
- Handling web requests with controllers
- Rendering dynamic views with Razor markup
- Using Entity Framework to write and read data to a database
- Using TagHelpers to create simple dynamic HTML forms
- Registering and authenticating users with Identity services
- Dynamically update portions on the server using partial rendering
- Using dynamic routing logic to customize URLs
- Exposing data with web APIs
- Leveraging custom configuration and logging
- Increasing application maintainability with dependency injection