Saturday, April 06, 2019

Creating a new MVC web application with .Net Core CLI

Start a command prompt by searching for cmd in .

To check what version of .Net Core that is installed type:

dotnet --version

Make a root directory for your web application.

mkdir MvcWebApp
move into the folder.

cd  MvcWebApp

Create a mvc web application (this step can be changed to create a webapi or empty web application, see the full documentation here:
dotnet new mvc
list the created files and folders.


Directory of C:\temp\MvcWebApp

<DIR>          .
<DIR>          ..
            36 .bowerrc
           178 appsettings.Development.json
           113 appsettings.json
           207 bower.json
           628 bundleconfig.json
<DIR>          Controllers
<DIR>          Models
           397 MvcWebApp.csproj
<DIR>          obj
           626 Program.cs
         1 428 Startup.cs
<DIR>          Views
<DIR>          wwwroot
8 File(s)          3 613 bytes
7 Dir(s)

ASP.Net Core and app.settings

Got a question from a colleague on how to handle different app.settings in ASP.Net core 1.1. When debugging in VS the command prompt shows that the ASP.Net Core web application is started in Development. So the question is how to use this to supply different app.settings on different environments.

A quick look in the documentation show that the recommended way to handle app.settings.json is by different files for different environments. 

Web front end - Angular 2

We are building an application in Angular 2. Writing down som findings to remember. The Angular CLI Command Line Interface that is used for scaffolding new projects and artefacts requires Node.js and NPM (Node Package Manager).


Node.js and NPM

Installation in Windows is made by downloading the latest installer from:

Or installing with Chocolatey:

Angular CLI

Install by using NPM:
npm install -g angular-cli

Create a project

To create a new project:
ng serve

ng new PROJECT_NAME creates the folder structure for the project and downloads the dependencies.
ng serve starts a web server with the project.

ng new TestProj

To be continued....