In this article, I will create an ASP.NET Core web application in which I will demonstrate how to verify that ASP.NET Core support new Project System is based on File and does background compilation. I am using Visual Studio Code Editor for this article; you can use Visual Studio 2015 or any other editor like Vim, Sublimer, Atom, etc.
Popular Editors for ASP.NET Core,
If you are not aware about Visual Studio Code Editor and Yeoman you can read these articles:
- ASP.NET 5 With Open Source - Part 1
- ASP.NET 5 With Visual Studio Code: Part 2
Go to Run and type “cmd” to open command prompt.
Change the directory and go to the directory where you want to create your ASP.NET Core Application.
Type “yo aspnet”,
Select Web Application, give the name of web application as "App_BGComplilation".
I ran all four commands cd “App_BGCompilation”, “dnu restore”, “dnu build” & “dnx web”.
Now we will find that it hosts the application on http://localhost:5000. This is the default URL, if you wish, you can change it.
I entered URL http://localhost:5000/Home/index in the browser and it display the page.
Background Compilation
Now open Visual Studio Code Editor to edit the code. Type “code .” on command prompt,
Now add a method in HomeController.cs,
public string AboutMe()=> "My Name is Banketeshvar Narayan Sharma. I am C# Corner MVP.";
Just save the changes and hit the URL http://localhost:5000/Home/AboutMe,
So we can see that I have not compiled the application but I am getting the new action without compilation. Now we are sure that in ASP.NET Core compilation is done in background.
File System
Open the path where web application “App_BGComplilation” has been created go to “wwwroot” add a file “ReadMe.html”,
Now hit the URL http://localhost:5000/Readme.html in browser and you can see that it is displaying the page. It means it is based on the file system. We do not need to add this file anywhere like inside .sln file or include the file in project.
In this article we have seen that ASP.NET Core use the power of Roslyn and DNX to create project based on file system and do the background compilation.
Read more articles on ASP.NET Core:
- Creating HTTP/2 Supported Website with ASP.NET Core & Hosting In Windows 10 (IIS 10.0.x)
- ASP.NET 5 with Open Source - Part 1
- ASP.NET 5 with Visual Studio Code: Part 2
- Creating ASP.NET 5 Web Application with Visual Studio Code
- Resolving ASP.NET 5 DNVM Upgrade Issue And Changing DNX Version