In my last post we saw how exactly we can deploy the web application in Azure using Visual Studio. Today we will see the new major changes in ASP.NET 5.
ASP.NET 5 is an open source web framework for building modern web applications that can be developed and run on Windows, Linux and the Mac. It includes the MVC 6 framework, which now combines the features of MVC and Web API into a single web programming framework. ASP.NET 5 will also be the basis for SignalR 3 - enabling you to add real time functionality to cloud connected applications.
First major changes is related to the project system. Projects in ASP.NET 5 are now based on File System. So if you need to add any new file or directory in the project then all you need to do is to place it in the proper file system and it will automatically get added in the project. So user can now edit the source code, save the file and build will happen dynamically.
Another new changes in ASP.NET 5 is the unification of ASP.NET MVC + WEB API. In MVC 6, Web API is merged with MVC, it means we will now have one set of controller class, one set of attributes, model binders etc. Even with these new changes, all our old projects will still work fine is Visual Studio 2015. Now lets go for some demo, since I have a MSDN Subscription I have already downloaded the Visual Studio 2015 RC version. You can download it from here. Lets create the project as shown below :
After you select "ASP.NET Web Application" and click OK, you will get a new window asking to select the template as shown below:
And once you select Web Site and click ok, new ASP.NET 5 project will be created. And when I will run the project I will get the below output.
As I said before the folder structure in ASP.NET 5 is based on File system, so the folder organization what you see in the Visual Studio is same as the File system. It also means whatever changes I make in that folder structure will be immediately reflected in the Visual Studio project. So if add Images folder as shown below than it will be automatically added in the Visual Studio project too.
Now lets see how exactly dynamic compilation works. Before that make sure you are not running the web application in Debug mode, since in Debug mode Dynamic Compilation is not yet supported. Run the application through Ctrl + F5. Now lets add new Controller called as "MusicController" in the Controller folder as shown below.
After adding the above file, refresh the web application and browse to "Music" and you will see the below screen.
What we did above is exactly the dynamic compilation. You can even edit the file and it will be reflected automatically and we don't have to build the application again. In my next post I will show more feature which are coming in ASP.NET. Till than Happy Coding!!!