Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

ASP.NET 5 Part – 3

4.00/5 (2 votes)
15 May 2015CPOL4 min read 16.7K  
ASP.NET 5 Part – 3

Introduction

In today’s discussion, we’ll delve further into some more interesting features on ASP.NET 5. So, let's begin the show. Now, let’s talk about the different CLR Types available with this project. So, when I talk about different CLRs; there are actually 2 versions of CLRs. The first one is the usual one which has the full blown version of CLR which we have been using since its inception. Another one is the minimized version or also known as cloud optimized version of CLR. Now, let’s go ahead and check project settings.

37th

As you can see in the above screen shot; my default setting is against full blown CLR which is running on the X86 machine. Now, if you see the drop down shown below, you will notice that I also have the option for cloud optimized version.

38th

Now, let’s change the environment to cloud version and then run the app and inspect the output of the greet controller which we created in the previous section. It should print my name there.

39th

Now, let’s go ahead and debug this controller. So, now when I refresh the page, it will hit the breakpoint as shown below.

40th

Here, when I go in the modules section as shown below in the screen shot, it will list the complete flow. So, here you can see from where all the binaries are loading. Basically modules are nothing but have one to one mapping with assemblies. But, you can also have multiple modules per assembly. Now, this module window is showing me what all modules are loaded in the application.

41th

43rd

Now, one point to note here is that all these modules are coming from one location that is from user’s location as highlighted above. Let’s jump to this location for a minute and inspect the same.

44th

Now, when I go inside there; I can see that there is nuget package file or NUPKG file which is around 14 MB.

45th

This is complete Core CLR. Can you imagine? Now, what I can do is I can simply take this file and copy to a different system my .NET Core version is ready. This bin directory here is the extracted version of this nuget package as shown in the below screen shot:

46th

Also, when you go to the runtime folder and go to full blown CLR folder as shown below,

47th

you will notice that size of the NUPKG file is very less compared to Core CLR version. Confused?

48th

In case of full blown CLR, all components get loaded from GAC (Global Assembly Cache) not from here. But, it doesn’t mean that there is no centralized repository for Core CLR. So, if you go to the below location; you will find packages folder.

49th

So, now this will be the centralized repository for your Core CLR.

50th

So, whenever we install any dependencies, it will sit here in this packages folder. So, ASP.NET 5 completely embraces nuget package. We manage dependencies via nuget package. We can have CLR stored through nuget package. Hence, these packages folders are referred to as Global Package Cache.

Now, project.json is not only used to have the nuget dependencies only. we can have different project dependencies also listed here within the same solution. For example, let’s go ahead and add class library project to the solution folder. Make sure you install Vnext version of class library which means this class library project can have all the flexibilities of dynamic compilation that we have been using so far.

51th

Once you added the project, your solution will look like shown below. So, even the new project gets added under the src folder.

52nd

You will also notice that this new class library project also added new project.json file which also lists the dependencies accordingly for running Class library project.

53rd

Now, if I have to use this project in my web project; then I just need to include this newly created project in the dependencies section of project.json file of web project as shown below:

54th

55th

Now, when you don’t provide the version name against the package or project, it will pull the latest one. Let’s go ahead and create some method in the class library project to return some meaningful thing.

56th

Let’s use the same in Greet controller.

58th

59th

With this, I will wrap this session. In the next section, we’ll delve further into new features of ASP.NET 5. Till then stay tuned and happy coding.

Thanks,
Rahul Sahay

83 total views, 79 views today

 

Image 22

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)