ASP.NET Core Project Layout in Visual Studio

Hi, let's explore the project layout of ASP.NET Core in Visual Studio 2015 and see how they're organized and work together.
 
The sample application that we created in Getting Started looks like the below in solution explorer in my Visual Studio 2015 Professional.

 

The layout is completely different than earlier versions of ASP.NET. Possibly you might have many questions. I will try to figure them out one by one:
 
Question 1: What is "launchSettings.json" file under Properties folder? What's the purpose?
 
 

As the name of the file suggests, launchSettings.json file contains the settings related to application launch. It holds project specific settings associated with each debug profile (Development / Staging / Production etc.). You can define different settings for different debugging profiles.
 
As you can see in the file above, I've two debugging profiles, i.e. "IIS Express" & "Web".
 
 

You can manage settings for each profile in debug tab of project property menu:

 
 
As I create a new debug profile in project properties, it gets reflected in launchSettings.json file immediately.
 
  
 
 
 
Visual Studio supports multiple debug profiles, associated with IIS express and commands defined in project.json 
 
Question 2:  OK, so what happens with if I chose or configure different profiles?
 
ASP.NET 5 ships with support for 3 different servers:
  1. Microsoft.AspNet.Server.IIS
  2. Microsoft.AspNet.Server.WebListener (WebListener)
  3. Microsoft.AspNet.Server.Kestrel (Kestrel)
So by default, there will be 3 different profiles. However, it also depends on the commands section of "project.json". I will be talking more about project.json in a later post.
 
You can change the active profile by selecting it in Application Properties settings and when you start debugging, it will pick up those settings and compile the application as per the defined settings. Simple as that.
 
Let me elaborate. For example, if I select "IIS Express" as Launch mode in one of my Debug profiles, it will use IIS Express to launch my app:
 
 
 
 
 
  
 
When I select the "Command", it uses DNX command line tool to compile and launch my app: (We will see how CLI tools work in here later) 
 
 
 
  
 
 

 

Few changes from earlier versions of ASP.NET: 

 
 
 
A Quick comparison: 

  
In ASP.NET 5 solution explorer reflects your project folder. You can directly add any file/folder outside Visual Studio and it will reflect inside solution explorer in real time. It keeps watching the project folder for changes. Only the files in "wwwroot" folder are accessible publicly. ASP.NET 5 uses a white-listing approach for file access. If you mark any file as accessible (by putting it in "wwwroot" folder), only then will it be available to access. Any file outside "wwwroot" folder is blocked by default.
 
There are two variants of "References" in ASP.NET Core. Server Side and Client Side. In earlier versions of ASP.NET we had Nuget Package Manager for managing server side references. ASP.NET Core additionally includes "Bower" for managing Client-Side dependencies. So, you should find "Manage Bower Packages" along with "Manage Nuget Packages" when you right click the application in solution explorer.
 
I could not find this option at first, so I selected "Manage Nuget Packages" and installed "Bower" from there first.
 
 
 
And there I have "Manage Bower Packages":
 
 
 
Browse and install any of the available client-side package from there. It installs all the dependencies for the selected package as well. Here, I'm going to install bootstrap
 
  
 
Here's how my solution explorer looks after I've performed all the actions above:
 
 
 
You can see, it has installed a jQuery package automatically which was a required dependency for Bootstrap. But still, the packages are outside "wwwroot" folder and won't be accessible to a browser. We need to move them to wwwroot folder somehow to make them work.
 
Let's see how to do that in the following post. Also, we will explore how "Startup" Class and "project.json" files work all together.
 
Hope you enjoyed reading. Please share your thoughts and feedback using comments section.

Read more articles on ASP.NET Core: