dotnet-core-hacknight-2017

Run the Web template and run the output

dotnet new web
dotnet restore
dotnet run

View Changes

Add MVC

dotnet package add Microsoft.AspNetCore.Mvc
dotnet restore
  • Add services.AddMvc(); to the ConfigureServices method.

  • Add app.UseMvcWithDefaultRoute(); to the Configure method.

  • Create a Home controller and Index action.

View Changes

Create a CatApi project & setup a solution to link everything together

dotnet new library
dotnet add package System.Xml.XmlSerializer
dotnet restore
dotnet new sln
dotnet sln add ./src/Web/Web.csproj
dotnet sln add ./src/CatApi/CatApi.csproj

View Changes

Create the API library code

View Changes

Add a reference to the API library from the MVC project

dotnet add reference ../CatApi/CatApi.csproj

View Changes

Configure MVC to automatically inject the new service into a controller

dotnet restore
dotnet run

View Changes

View random cats

Add logging to the API client to help with debugging.

dotnet add package Microsoft.Extensions.Logging

Add a ViewModel, call the API etc., add a View to display everything.

View Changes

Add tests

dotnet new xunit
dotnet add reference ../../src/CatApi/CatApi.csproj
dotnet restore

Don't forget to add it to the solution.

dotnet test ./tests/CatApiTests/CatApiTests.csproj

View Changes