asp.net core demos

18
ASP.NET CORE QUICK START

Upload: erik-noren

Post on 21-Mar-2017

123 views

Category:

Software


1 download

TRANSCRIPT

Page 1: ASP.NET Core Demos

ASP.NET CORE QUICK START

Page 2: ASP.NET Core Demos

ERIK NORENSolutions ArchitectSoftware Developer 15+ YearsSoftware Tinkerer Since Commodore 64Hardware HobbyistTwitter: @ErikNorenGitHub: ErikNoren

Page 3: ASP.NET Core Demos

ASP.NET CORE QUICK START.NET Core or .NET Framework

Page 4: ASP.NET Core Demos

ASP.NET Core on…

.NET FRAMEWORK• Easy to Add Project

References• Windows Only• Create Libraries as Class

Library

.NET CORE• Primarily Leverage NuGet

Packages• Cross Platform• Start with Portable Class

Library then convert to .NET Standard

Page 5: ASP.NET Core Demos

ASP.NET CORE

• Developed the same regardless if you choose .NET Core or .NET Framework• .NET Core and .NET Framework don’t have feature parity so some differences there

• Is a Console Application with a built-in web server (Kestrel)• Integrates Dependency Injection in a smart way and takes advantage of

knowing DI is available from the start.• Heavy use of NuGet packages and separation of abstractions from

implementation make DI into class libraries easy.

Page 6: ASP.NET Core Demos

ASP.NET CORE QUICK STARTConfiguration

Page 7: ASP.NET Core Demos

CONFIGURATION• Multiple Providers for Different Sources

• JSON Files, Environment Variables, INI Files, XML Files, Command Line Switches

• Configuration Values Stored in Single IConfiguration Object• Configuration Sources Converted to Key Value Pairs• Key Names are Flattened Hierarchy Using Colon Delimiters

• Key• Key:SubKey:AnotherSubKey

• Bind Configuration to POCO Object for Easy Use

Page 8: ASP.NET Core Demos

CONFIGURATION

SOURCE{ “Version”: “1.0.preview1”, “Build” : { “Target”: “Release”, “Date”: “2017-02-16” }}

ICONFIGURATIONVersion = 1.0.preview1Build:Target = ReleaseBuild:Date = 2017-02-16

Page 9: ASP.NET Core Demos

CONFIGURATION

• Added to DI Container as Singleton• IOptions<MySettings>• IOptionsSnapshot<MySettings>• IOptionsMonitor<MySettings>

• services.Configure<MySettings>(…)• Settings at time of application start• Settings as they currently are*• Settings as they currently are**

*Provider must support ReloadOnChange. Available in version 1.1.0**Provider must support ReloadOnChange. Has change event you can hook to detect changes.

Page 10: ASP.NET Core Demos

ASP.NET CORE QUICK STARTConfiguration Demo

Page 11: ASP.NET Core Demos

ASP.NET CORE QUICK STARTLogging

Page 12: ASP.NET Core Demos

LOGGING

• ILoggerFactory can be injected to set up and configure logging• ILogger<T> can be injected in constructors to log messages• ILogger comes from Microsoft.Extensions.Logging.Abstractions• Easy to include into other projects using the interface• Dependency Injection will inject the implementation from the application• Avoid circular references, shared classes, etc.• Change logging provider in container with no application code changes

Page 13: ASP.NET Core Demos

ASP.NET CORE QUICK STARTLogging Demo

Page 14: ASP.NET Core Demos

ASP.NET CORE QUICK STARTClass Library References

Page 15: ASP.NET Core Demos

Class Library References• Separating logic into separate projects is common• .NET Framework projects continue to work as they always have• .NET Core requires Portable Class Libraries targeting .NET Standard• NuGet Packages can contain both .NET Framework and .NET Core

libs• To see if a NuGet package is compatible, look at its dependencies• .NET Framework 4x will work in ASP.NET Core using .NET Framework• .NET Standard 1.x will work in ASP.NET Core using .NET Core

Page 16: ASP.NET Core Demos

ASP.NET CORE QUICK STARTClass Library References Demo

Page 17: ASP.NET Core Demos

QUESTIONS?Erik NorenSolutions ArchitectSoftware Developer 15+ YearsSoftware Tinkerer Since Commodore 64Hardware HobbyistTwitter: @ErikNorenGitHub: ErikNoren

Page 18: ASP.NET Core Demos

RESOURCES

• Demo Code Samples - https://github.com/ErikNoren/AspNetCoreDemos• ASP.NET Core – https://www.asp.net/core• ASP.NET Core Source – https://github.com/aspnet/home• Microsoft Docs – https://docs.microsoft.com/• .NET Standard – https://github.com/dotnet/standard• .NET Core Roadmap – https://github.com/dotnet/core/blob/master/roadmap.md• .NET Foundation – https://dotnetfoundation.org/