Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

ASP.NET 5 – Part I

0.00/5 (No votes)
8 May 2015 1  
ASP.NET 5 Features - Part 1

In this section, we’ll see the major changes in ASP.NET 5. The very first change is on the lines of Project system. Projects are now based on File System. So, all you need to do is add something to a project, say new source code file is just to place the file in the right directory. So, you can edit the source code file, save the file and the build just happens dynamically. Thanks to new Roslyn compiler which compiles the source code in memory which allows for faster build and faster refresh.

The project structure itself changed from previous versions. Also, one point to note while building application, we’ll be having two different options of choosing runtime. First is the full blown runtime as 4.5.1 or greater than that or the second option we can have cloud optimized runtime also called core CLR. Here, all the pieces like JIT Compiler, Garbage Collector are packaged and designed keeping high throughput and low memory consumption in mind. And now the application can have this cloud optimized environment embedded with the application which makes it easier to have true side by side version and by embedded, it means you can deploy the .NET Framework by copying the nuget package. So, the idea behind this cloud version of .NET runtime is; it should be platform independent which means it can also run on MAC and LINUX machine.

Another great fact about the new changes in ASP.NET 5 is the unification. So, now:

MVC 6 = ASP.NET MVC + WEB API

In MVC 6, WEB API is merged with MVC. This means we will now have one set of controller class, one set of attributes, model binders, etc. Also, it no longer relies on the namespace system.web which means it is easy to self host and run the core CLR. Now, with these changes in place, it doesn’t mean that your existing projects won’t work in VS 2015; It will work as smooth as it was in earlier versions. Now, let's go ahead and start the demo. I already have RC version of VS 2015 installed on my 2ndry machine. Let's go ahead and create a new project.

1st

Now, the below window is very much familiar to previous version. Here, I am interested in the new templates introduced. Hence, I am going to create a new project with ASP.NET 5 Website. This project will give me all the required components to run an app as shown below in the screen shot.

2nd

So, below shown window will be the new window for ASP.NET 5 project.

3rd

And when I run the same, it will produce the below output. Very traditional MVC APP.

4th

5th

6th

One point to also note is that now folder organization in the file system and solution explorer is the same as you can see in the below screen shots.

7th

8th

This also means whatever changes I make in the file system under src folder, it will take effect in VS. Let’s create myImages folder in the file system with one image there. As soon as I added the image in the file system, it gets automatically synced with Solution Explorer.

9th

10th

Now, let's create one controller, say GreetController but from the Notepad; this is just to prove the point that we don’t need to build the app to take the code changes effect.

13th

Now, after saving the same when I refresh the browser, it will return the new controller’s output. So, this is called dynamic compilation.

14th

Thanks for joining me for the first edition of ASP.NET 5. We’ll delve further in coming topics. Till then, stay tuned and happy coding!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here