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: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new?tabs=netcore2x)
dotnet new mvc
list the created files and folders.

dir
C:\temp\MvcWebApp>dir

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).

Installation

Node.js and NPM

Installation in Windows is made by downloading the latest installer from: https://nodejs.org/en/download/

Or installing with Chocolatey:
https://chocolatey.org/packages/nodejs

Angular CLI

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

https://github.com/angular/angular-cli#installation

Create a project

To create a new project:
ng new PROJECT_NAMEcd PROJECT_NAME
ng serve


https://github.com/angular/angular-cli#usage

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....