Dream. Dare. Do – that is Suyati’s work principle in a nutshell.
Say hello to ASP.NET 5, a lean .NET stack that will change the way you build modern web apps! Formerly known as ASP.NET vNext, this next generation ASP.NET provides a modern framework for web and cloud, taking things to the next level. It is built from the ground up to provide an optimized development framework for apps that are either deployed to the cloud or run on-premises. A significant redesign, full open source and available on GitHub, ASP.NET 5 uses cloud-optimized version, that is enhanced for server scenarios like low-memory and high-throughput. Get to know the all new powerful ASP.NET 5 through our webinar.Agenda: 1. What is ASP.NET 5? 2. ASP.NET 5 Features - Cross Platform - Open Source - Cloud Friendly - Host Anywhere 3. DNX, DNVM 4. Introduction to Visual Studio 2015 5. Dependencies and Packaging 6. Bower, grunt and npm 7. Hosting 8. Kestrel 9. Q&A VIDEO TRANSCRIPT
What is ASP.NET 5?
We’ll be looking at ASP.NET files. What is ASP.NET files? Then we’ll be focusing on four different elements of Asp.Net files and the modern workflow so we’ll be focusing on the cross-platform, what ASP.NET5 has to offer to cross platform, cloud friendly and performance. Then we’ll be looking at DNX and DNVM. What is DNX and DNVM? We’ll be having a closer look at both. Then we’ll quickly take you to the new features and tools available in Visual Studio 2015. Then we’ll be talking about dependencies and packages, how we can handle dependencies and packages in ASP.NET5. Then we’ll have a look at Bower grunt and npm, how it is being integrated with ASP.NET 5 and VS 2015. Then we’ll have a look at multiple hosting options followed by Q&A Session.
ASP.NET 5 and the modern web
We have an exciting week coming up. We have multiple series of webinars on ASP.NET 5 coming up in the following weeks. The next webinar will be ASP.NET MVC 6 & the web API, so we’ll be doing a complete demo of how to build a modern web app using ASP.NET MVC 6. Then we’ll be developing a backend server application which you can leverage for your mobile application. So we’ll be developing ASP.NET 5 with the applications. Both these demos’ walkthroughs are planned for the next webinar which will take place by next week.
So moving on to the slides, what is ASP.NET 5? ASP.NET is a significant architectural upgrade done on the ASP.NET stack. So it is rebuilt from the ground up. It is linear now modular, cross platform and cloud optimized, so all these changes on ASP.NET 5 is emphasized on simplifying the development, hosting and maintenance, and it is targeted on modern web apps. So, talking about modern web, so we’ll be looking at what ASP.NET 5 has to offer on modern web across these 4 elements cross platform open source cloud friendly and performance. So what is actually Modern Web? When you’re talking about Modern Web developing a Modern Web application, the first thing that comes in your mind is Mobile First Design. So when you take a look at the tabs of Mobile users in the world you can’t avoid the mobile, the applications that perform on a mobile device.
So we can’t avoid the design, how it will look on mobile or tablet. So for a mobile first device you must have responsiveness. So a Modern web app will be responsive, it will be mobile first design. There are multiple java script designs which will make things easier for you. Modern Web App is a superfast App people don’t have to wait. People are not ready to wait for loading of the applications. They will not wait if the application is slower. The competition in the world market currently for the web application, there are multiple competitors to keep up with your competitor. You need to build a superfast app, you need to build a cool app for the modern web. So how to build a superfast app, it needs to be lightweight in size, in performance in whatever areas we can make it lightweight you need to make sure that the application we’re building is lightweight. It should not be heavy for making the application work faster and it should be cloud ready so when you take a look at previous ASP.NET applications, it is not fully cloud ready.
So you need a full .NET frame server that your code needs to be moved to server. It will change all the configurations there & .NET frame has to support whichever apps are there. So as a developer you’re not comfortable moving your to cloud. So cloud ready in the sense, so there needs to be less hindrance when developer moves the code to the live server. So it should be easily scalable so when you’re creating a modern web application. If you have a huge user base, targeting a multibillion user base for application you need to have multiple servers, virtual machines where your application will be running. So there the session states maintain session state should be a challenge. So if you’re developing a modern application it should be easily scalable. You should not worry about multiple VM scaling up to multiple servers. My app should not have any changes in terms of handling sessions or handling anything of that sort. Easy scalability is one thing and there is agility and platform independence.
So agility in the sense a modern application should be built very fast. So the development team should not get stuck on any packages or any libraries or any other dependencies that come around during the development of code. So the app should be agile enough for a modern web app to complete the project fast and the Modern Web App should be platform independent. You should be able to host your app in any of the servers or Linux or a windows server or any other server.
So moving on to next, Open Sourcing. Why is MS actually Open Sourcing .NET? MS wants to lay a .NET cross platform so .NET cross platform so you can have multiple servers multiple service client applications hosted on your server and to leverage a stronger eco system a .NET eco system, so when you look at the front end client library it is early separated from .NET eco-system. You have stronger server code on .NET and this can be utilized with the current bigger eco-system of the client side Java script libs & it can come up as eco-system. How this can be achieved? So we’ve come up to what MS is open sourcing in the later point. So this is the road ahead for the .Net How MS is visioning the .NET platform in this way, so we’ll be having multiple .NET, .NET core, ASP.NET 5 .Net compiler, IOT innovations etc. Everything they’ll be building on .NET will be available on the GitHub. So you have all the codes, .NET frameworks, compilers everything open Source now. It should be cross-platform as well and you can develop your .NET code MAC, LINUX and you can host it on anywhere as you wish.
What is open source?
Coming back to the previous slide MS is open sourcing multiple things. So what is actually MS Open Sourcing? MS is open sourcing .NET core 4 and 5 and they’re open sourcing core 5, I’ll come to details on what is core 5. Then they’re open sourcing run time components, compilers, and .NET Core 5 Libraries .NET Frame Work which is 4.6 which is full framework it’s not Open Source so they’re open sourcing ASP.NET 5, ASP.NET 4&5 .NET Core5 the libraries, compilers and runtime components.
Moving on to the next slide. What is actually meant by Cloud Friendly? As I mentioned it should be a seamless transition from on premise to cloud. So how this is possible, a seamless transition from on premise to cloud. So when you have an on premise application how you can have it on single cloud? So like I previously mentioned it should be easily scalable, so you don’t have to worry about what Session State you’re using on, On Premise application currently entire framework is part of the application so you don’t have to worry much on how on premise infrastructure or how on premise application easily migrate to the core. So then there are Core5 then there’s sconfig configurations so as a developer you can have separate config files in live environments and we ensure that it won’t break the code. So what it does is, instead it overwrites the code sconfig.json file in your server. You can keep your environment variable you can keep your connection string in. Make sure that your development code does not create any problem in your light side. Another thing is that entire framework is part of the application, so the previous slide which I’ve shown that What MS is actually Open Sourcing. So you can see that .NET Framework 4.6 and the .NET Core 5, so there’s 3 different run-time environments and great flexibility when you host your application. So you have 3 different runtimes which is the full .NET framework 4.6, the .NET Core 5 and cross platform CLR, it is yet to be released by MS you have the full .NET framework 4.6 and the .NET Core 5. .NET Core 5 is the subset of .NET framework 4.6 you have the minimal features in .NET Core 5 which is cross platform and open source. So this enables .NET apps to target the packages the server side packages which you need for your features. So you don’t have to include your entire framework to run your application. You also have the flexibility to target multiple apps when you’re hosting in server to run on the specific version you are mentioning in your app.The road ahead for .NET
That is a major change in ASP.NET 5. The entire framework is part of the app and it takes full advantage of PAAS when using ASP.NET 5. You can push your app to Windows without worrying about your server infrastructure, the OS there .NET framework version in your server. You’ve got your entire framework as part of your app so you can make a complete use of your PAAS when you’re hosting on your cloud. Then another thing is upscale automatically without worrying about session and state so you can scale whenever without worrying about the code
So you can run and debug in Cloud.
Another major thing ASP.NET 5 provides is that you can run and debug in cloud. You can host your apps in cloud you can connect your cloud configure in Visual Studio and you can debug your code, enable to have proper debugging activity.
So moving on to the next slide, performance, performance is what matters for any web app/app I would say. So what ASP.NET 5 has changed in terms of performance is, it has changed start up time of app there’s no system.dll it is no more in ASP.NET 5, so you don’t have to worry about it, so it enables your system to load faster so it runs your app quickly so it loads so fastly. If you look at each release of MS it is getting faster with each release. So you can expect a superfast app when the final ASP.NET 5 out there in the market. There is a performance optimized release every time. They are increasing the start up time every time they’re releasing a new version.
As I mentioned, about Startup.cs it loads faster and gives multiple options, you can add a middleware in the pipeline every time a request comes in, it can go through a middleware and you can have multiple authentications in Startup.cs file. As you can see there’s no full framework required so .NET full framework is 200 MB whereas the lighter version .NET Core5 it is just 11MB. Reducing the size of Core 5 means you have entire framework in app and it’s light weight. You can install all the packages you need through application and you don’t have to carry the 200 MB of 4.6 framework. It reduces compile time, you can edit code or refresh your browser to see the changes. So we’ll do a demo in the coming slides how we can achieve this then you don’t have to build the entire project to refresh or see your changes. And you have the flexibility to choose your own editor.
These are the major combined features of ASP.NET 5 you can have a flexible cross platform runtime. So that is the .NET Core 5 which is the subset of the full framework, you can have linear framework, modular framework and you can have the required framework as your app needs and you can install and run it in your app. There’s a new Modular HTTP pipeline so let’s have a look at ASP.Net 5 app in the latest Visual Studio.
So I’ll hand over to my friend here, Anoop, he’ll take you through the project structure how the request pipeline in the current ASP.NET 5.
Thank you, Rifaj. So now I’m going to create a sample ASP.NET App ‘Hello World’ Application For that I’m going to click on File> New Project. In this template you can see ASP.NET 5 Web Application, Class Library, Console Application. So now I’m going to create ASP.NET Web application for that I’m going to give SuyatiWebinar1 and click OK. Here in this template you can see new things like ASP.NET 5 Preview Empty, Preview Starter Web, Preview Web API, all the other things are available in the previous versions.
So I’m going to create an Empty Application first so I’m clicking on Empty and click OK, it’s generated. So if you look on the right side you can see the basic structure of ASP.NET 5 App in that there are few elements which are new things like root folder, dependencies, References, project.json, Startup.cs here the root folder is used for keeping the static files like css, java script files, images and all, but ASP guys are not familiar with these folders but in open source framework the static files are saved in these folders.
So next is Dependencies, it’s an empty application so there are no dependencies available now next look at the Reference inside that you can see 2 elements ASP.NET 5 & Core 5, the ASP.NET Core 5 is the subset of ASP.Net 5. Next thing is project.json this file is used normally to specify the files used in our application you can see many tags inside this project.json. We’ll discuss about it later. First we’ll go to Startup.cs , inside this we have a function called configure Each and every request will first hit on this function so if I give a debugger on this function you can see what will happen, it’s running and it has hit on the config function, so Rifaj you’d told me there are some middleware functions we can add on this Startup.cs.
Yes so I’ve mentioned about we can add the middleware on the configure class and see how Edit Your CS file refresh your browser walk and ASP.NET file, can you show that.
Yes, sure. For that I’m adding a middleware inside this configure here. I’m going to add app.Run(async context=>await.Context.Response.WriteAsync( ) Here I’m going to do Hello World.
And I’m going to remove this and going to run this one.
So your Hello World Application is ready in no time, so Anoop you’ve added a middleware here, It’s just simple writing “Hello World” to your browser. Without changing much we are writing Suyati Webinar and I’m saving the code then I go back to Browser and I refresh I can see the change reflected here.
So Rifaj, is there any complier to get this output?
So this’s been achieved. So all the compilers don’t get any file out of it. So let’s move on to the features, so it’s cloud-ready environment configuration so you can have the you have the project.json file the file that defines what an all files come in your configuration then you have the Unified Programming Model which Combines the MVC, Web API and Web pages. So in ASP.NET 5 MVC, web pages are merged into a single framework called MVC6 they’re also planning to merge work forms into MVC 6 so it is not yet done so we’ve currently MVC, Web API and web pages merged into MVC 6 so this merging removes duplication and multiple duplication when you have your web API running on your MVC Applications, you have multiple duplications like how you have it in the controller how you have the dependency resolver everything is duplicated in Web API and MVC.
So they’ve merged everything together so now you don’t have a API controller base class you have only a controller, the API Controller Base Class has been merged into the controller and you don’t have multiple dependency resolvers only have a dependency resolver which is in-built in their app, so that’ how MVC 6 has been. You don’t have a Web API separate or web page separate everything has been combined into MVC 6 Ability to see the changes without rebuilding the project that’s just we’ve been.. The side by side versioning of .NET Framework. When you see the sample app you can see references to ASP.NET 5 ASP.NET Core 5.0 so this is just the same in your project.json file, so I’m removing my full framework which is my 4.6 Framework from my json then saving. There you go you can see that it is restoring in your solution explorer and you only have ASP.NET core 5 which is the modular the linear ASP.NET core framework. So you only have your ASP.NET server, IAS which allows you to run in the IAS Express.
So if you want to add your full framework not the ASP.NET core, the linear framework. So when you add back both the frameworks you can see it’s being added back. So you can target your .NET framework, so if you want to target only your .NET Core, you want to enable the functionalities of cross platform and the functionalities of modular framework and the required packages you want then you can make use of the ASP.NET Core, and if you want your existing ASP.NET 4.5 and the lesser app to ASP.NET 5 you can make use of the full framework which is ASP.NET 5.0.
But if you’re targeting ASP.net core files which is the Linux cross platform framework. If you have to make some changes in the application basically, so, you don’t have a system about web.
You have multiple changes in the pipeline. Everything, you have to change the code to make it work on ASP.NET framework.
Then you have the side by side versioning of .NET framework. So when apps on a server depends on a single system wide installation of .net framework, all of the app has to run on the same version of .NET. So when I have a single version installed, I have to ensure that if I upgrade to the new version, I need to ensure that all my applications are not affected with that. In ASP. NET 5, I can have the flexibility, you won’t face any issues like that. I have the flexibility to choose which .NET version to use for each application. So different applications can run on different .NET versions and for ensuring the different applications to run on the different versions you need to have the core CLR. You need to target the core CLR which is the minified CLR of the cross-platform CLR.
Another feature is the Built-in Dependency Injection. So as I mentioned, you don’t have to make use of dependency resolver of web API or dependency resolver of MVC. You have the dependency resolver inbuilt. So you can register your container, register your services in a container, and you can call it directly, you can call it, how you used to call 3rd party dependency resolvers in your controller. You can use the same way in your start-up class, or you can use it in your helpers, and you don’t have to worry about the dependency injection. It is in-built in your ASP.net file application. And with the ability of self-host or host on IIS you don't have to depend fully on IIS, but it is still a powerful platform to host your ASP.net platform. But you can make use of the self-host platform and you can run your applications with outside of IIS.
Then another thing is open source in GitHub. When you look at ASP.net home repo in GitHub you can see it is fully open sourced. You can see all the open source things which is available, which is made as open source by Microsoft is available in GitHub.
What all changes, what all things that Microsoft is doing it is available through GitHub.
Everything is available as open source in GitHub. Major change that has been done by Microsoft in the .net platform.
Then the Simplified Dependency Management. We'll have a look at how the dependency is managed and the packages are managed in the coming slides.
DNX and DNVM
Then coming to the DNX and DNVM. What is DNVM? We used to hear KVM first. Now it is DNVM. So KVM was the K version manager. K letter was the code name of ASP.net 5.The version manager but now it has been renamed to DNVM. DNVM stands for dotnet version manager.So currently there's no KVM. KVM has been renamed to DNVM. And dnx which was k runtime environment it has been renamed to DNX, and DNX stands for dotnet executable, dotnet cross platform, or whatever the x stands for.And the DNX is a portable CLR host, and you need to boot the CLR, using windows or windows phone or any platform you run. So the CLR is not part of your operating system it is a part of your application and whenever your application is running it boots up along with the application. So you need to make sure that you're targeting dotnet core when you're running when you're choosing DNX CLR.
So let us have a look at what DNVM is:
So, DNVM lists, I have the DNVM installed, before going to the DNVM keys let us have a look at how we can install DNX or the DNVM. First we need to install DNVM, then we need to update the DNX. DNVM is something that install the DNX. So how to install DNVM? To install DNVM you can have the optimistic and the stable(ish) KVMs.DNVM is still optimistic, it is still called the bleeding edge, and it might break at times. It is currently under development, they haven't the released the stable version yet. So if you want to install the Optimistic DMVM, you have this powershell script. And it will install it from the GitHub repo and everything will be ready in your system. So you can install DNVM with the script which is available in ASP.net home repo. So DNVM list is the command to list all the DNX versions installed in my system. So currently I have 4 DNX installed and I have targeted 2 here beta5-11556 and 11351. So if I need to update DNVM, I mean DNX, I can give the code as DNVM update. It will check for the latest version of DNX, it is DNX update, it is upgrade not update.
This code will get the latest DNX version and it will install the latest DNX version in your system. So where can you see where the DNX installed through the explorer. In the user profile you can see a .dnx folder and all the runtimes are here. So let's go inside this. I have the dnx here. This is the dnx which makes sure that which runs the application behind. So I have the latest already installed. That's what it is coming like this.
Visual Studio 2015
So it is, then we have the DNX and DNVM, then moving on to the next slide, so Visual Studio 2015. You have a lot of tools coming in, you have multiple features coming in Visual Studio 2015. So Anoop will explain on the new features that is available in Visual Studio 2015.
Thank you, Rifaj. And we can go through each and everyone right. First one is
Cross platform development. This cross platform development is enabled by using this core CLR. We can add the core CLR with each and every application. So by using that we can develop this cross platform development. Yeah! This is the basic structure, right? We can take a web application from it. Inside this, this is a sample web application that we created. So the sample web application will have your default controllers. So the dependencies like Bower and NPM will explain what bower and NPM are. So this was the default configuration files. This is the default configuration files. This has been created from new project and selecting the asp.net starter web. Previously we created the review started new project. This is the startup project, empty project that we've created.
Simplified dependency management
So here you can see the dependency style bower and NPM.
Bower, Grunt and NPM
These Bower and NPM is the package managers which can be used to manage the packages from the client side.
For configuring this bower and NPM, there is a Jason file called bower.json. Here you can configure the required js file required for the client side application.
And on the client side, libraries which are available in NPM is available here. So you can select whichever thing is available, we have a brilliant intelligence which enables you to select all the packages here. That is a cool feature that visual studio has brought in; to select the features through intelligence. And it can have the version also mentioned.
The next thing is Grunt.
Inside this gruntfile you can specify the files, js files or other resources that you need to minify and during the bunding(?) process you can specify the path here. During the compilation the grunt task will automatically convert it as minified files.
The next one is package.json. We know that the asp.net file is packaged kind of mechanism, following a packaged kind of mechanism. Which are the packages, which you need only we need to add inside your application. So the required packages, you can configure the required packages inside this package.json. The intellisense is also available here also.
So moving on to the slides, these are the features available. We have a brilliant intellisense for bower and NPM. Visual Studio tools for Apache Cordova and Visual studio emulator for Android. So we can build an android application in Visual Studio 2015. You have the android emulator along with the CTP, so you can build an android application in Visual Studio 2015. And you have .network framework 4.6 along with 2015. and you have the flexibility to add the .net code the lesser framework than the modular one.
You have debugging and diagnostics improvements. You have all the improvements in debugging and diagnostics, typescripts, unit tests, application insights, everything has been included in the latest version of 2015. The preview version is available and you can go to visualstudio.com and download the preview version. You have your CTP version, the technical preview version available as well. The community technical preview version is available as well. So for demo they will use the CTP version.
So moving on to the next slide. We have already discussed about the Simplified Dependency Management, how dependency management is being handled. So you don't have to directly add the assembly references here. All the assembly references are available in the nugget packages. As and when you require those packages, you can add it there.
Use nuget package manager or project.json file. It will allow you to add the required dependencies from nugget. If you want to add any dependencies here, if u want to add Microsoft.asp.net. All the things are available through Intellisense here. You can add your nugget packages through the project.json file and you can have your version number mentioned as well. So 6.0 beta 3 is the version available for ASP.net. MEC on saving this you can find these changes on both the full framework. You can find the nuget packages added to both the frameworks. You also have the option to add the nuget packages via new nugget package manager console. Through the nuget package manager console you get to add beta version and this is a new feature coming into Visual Studio. There are few options by which you can add packages in your application. No dependent packages are really dependent on the project.json. MEC. Asp.net is having multiple dependent packages though dependent packages are not displayed there. So coming back to Bower, Grunt, and NPM.
So NPM where Bower and Grunt came from. It is also created for Node.js. And instead of navigating around the web and downloading project resources, you can download all the resources that is available in NPM. It’s a bigger ecosystem there and you can have all the utilities, all the packages, and you can make it through NPM.
So Kestrel. Kestrel is a new cross-platform OWN web server for ASP.net.
Instead of IIS, Kestrel is the thing that you need to target. ASP.net file application does not talk directly to the web server. It is facilitated through feature interfaces which enables ASP.net applications to switch between hosts. So you can switch between multiple hosts, you can target ASP.net, I mean you can target IIS, you can target your own host, you can specify everything from the project.json file.
So that’s all we have for today’s webinar. We’ll be taking you deeply on ASP.net MEC 6 and web API in the coming webinars. We’ll be explaining self-host your applications. We’ll running those demo projects and applications in IS express as well as in the server of the local host or web server mentioned on the project.json fil. That’s all we have for today and back to you Muktha.
So, thank you, Rifaj, and thank you, Anoop. It was a pleasure to have you both on board.
Q & A
That was a very informative session. Now it’s time for the Question & Answers. We’re ready to address your questions. Type in the question using the question feature on the Go To Webinar. We have the first question for the day.
We can create but we can’t use the core CLR for creating these web form applications. We have to use the full framework for creating the web form application.
And ASP.net 5 the final version is expected to have the web forms also combines along with web app, MVP, web apps, and web pages. And if you want to migrate your existing application, you can always do that making use of the .net full framework the 4.6. There won’t be much changes, much modification that you need to do. You can have your web forms moved without much changes.
So we’ve listed the multiple version here. My DNVM list will list out all the version that is installed here. And I can target, I can specify. Taking going to this project, going to the properties and on the debug. So there I can choose the profile. I can have the Salesforce also when you are adding the Salesforce option in the project.json file.
You have a specific run time, this is the place where you can select your CLR. If you want to have the kre code clr, the beta 3, so whichever version that you want you can specify it here.
3. Why not install client packages via nuget?
4. Is okay to update to ASP.net 5 now?
That’s a good question actually. I would say you can start developing. But there are breaking changes coming up in each preview version, if you have an enterprise application currently it is better to wait. You can wait for the final release and if you start developing now, if you are ready for the bleeding edge thing, you are ready for accepting the breakages for the newer releases and preview releases, you can start building a newer application in asp.net 5. But if you are targeting an enterprise application to upgrade, it’s better to wait for the final release of the visual Studio and ASP.net 5.
If you have any other queries, please feel free to write back to us at firstname.lastname@example.org
Rifaj is a Senior Developer at Suyati Technologies who works mainly on the platforms such as .Net C# and on WebAPI, Cloud etc. Apart from being a passionate technologist, he is also a social media enthusiast and is keen on latest gadgets. Rifaj is also an ardent supporter of the Football club ‘Chelsea’ and absolutely loves to spend time watching Football.
Anoop has been working as a Software Developer with Suyati Technologies, mainly on the platforms C# .NET MVC. He likes to follow the pulse of Social Media regularly and is an active tweep, who tweets about Technology in general. This makes him an enthusiast on working with Social Media Integration APIs. Besides Technology, he is also a die-hard Cricket fan.