Download presentation
Presentation is loading. Please wait.
Published bySarah Johnston Modified over 7 years ago
1
ASP.NET 5 “A lean and composable framework for building web and cloud applications”
2
ASP.NET now Built upon a monolithic .NET 4.* framework
Slow release cycles BUT! Stability is not an issue – good quality and cohesive, unified platform Typically one FW version installed / machine – is that really an issue in the public cloud? Well-defined set of events in the HTTP request pipeline Extensibility through Modules, Handlers etc. Goes hand-in-hand with IIS How do you innovate when stability has to be maintained on millions of devices without introducing a breaking change?
3
ASP.NET 5 Concepts Cross platform Modular EntityFramework Mvc
Antiforgery CORS Diagnostics Identity Caching Routing IISIntegration …
4
ASP.NET 5 Concepts Truly Open source -– check repos at github.com/aspnet not only “source opened”, public GitHub repos with issue tracking non-MS contributors participate, community members can (and do) send pull requests
5
ASP.NET 5 Concepts Why not?!
“Why did you open source the new ASP.NET?” An attitude / strategy change at Microsoft towards “Mobile first, Cloud first” Why not?!
6
ASP.NET 5 Concepts Deeply inspired by Node, Ruby…
Run your code anywhere, with any runtime (NVM, RVM) Light-weight, componentized frameworks Fast iteration cycles during development Provide a strong REPL experience - coming to C# Web app hosting is not tied to IIS – Kestrel, IIS, WebListener Wide palette of dev tooling – still best quality IDE support on Windows! Don’t fear the CLI Composable and minimal – achieve high performance If you need a raw TCP socket, so be it Cloud-ready + rich tooling in Visual Studio 2015 Right click, Publish… experience further improved Azure Web app, Docker on a Linux VM
7
Dev stack comparison current vs vNext
8
Current ASP.NET stack
9
ASP.NET 5 Development stack
10
.NET Core = CoreCLR + CoreFX
CoreCLR = .NET Core Runtime + mscorlib GC, JIT compiler, base .NET data types, low-level classes CoreFX = foundational libraries collections, file systems, console, XML, async, SqlClient… /coreclr /corefx Works with ASP.NET, that’s OK. But console tools as well Even more: on Connect(); event native compilation was announced! This means .NET native on Windows, Linux, OS X
11
ASP.NET 5 & .NET Core are RC What does it mean? Far from RTM?
Working on ASP.NET 5 for ~ 2 years “Go Live” support for prod systems Feature complete No breaking changes are expected in code, only minor API changes RC 2 will come until 2016 – DNX will be sliced into 3 pieces RTM is expected by the end of February 2016 Further performance improvements are to be expected until RTM
12
Full .NET FW vs .NET Core Which to choose when?
Cross-platform – Windows, Linux, OS X,… Deploy FW with your app – multiple FWs on the same machine Runs in its own isolated unit – unaffected by system-wide patches Microsoft puts huge invests into it, innovation takes places here easier You want a fully open source stack Full .NET FW Reliable & fault tolerant production grade applications Windows-heavy applications When cross-platform is not an objective
13
DNX SDK + Runtime environment = all you need to build & run .NET on any platform Managed entry-point discovery Host process for your .NET application (ASP.NET & console app) provides a set of services to applications through DI e.g.: IServiceProvider, IApplicationEnvironment, ILoggerFactory Hosts the CLR Different “flavors” (CoreCLR, Mono, Full .NET FW) Open source friendly load dependency’s source instead of binary build in-memory debug “Develop on one platform. Run it anywhere” How to obtain it?
14
DNVM – 1: .NET Version Manager
Manage installed DNX’s on a machine Strong resemblance with NVM and RVM How to get? Windows: part of tooling that comes with AspNet5.ENU.RC1.msi OS X / Linux curl -sSL | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh What you get? Just a bunch of PS / bash scripts
15
DNVM – 2: command line tool
Available DNVM commands
16
DNVM – 3: How’s a DNX installed?
dnvm install latest –r {RUNTIME FLAVOR} Runtime can be: coreclr | mono | clr
17
DNVM – 4. Choose an installed DNX
dnvm list dnvm use Just a text file in .dnx/alias folder Persist: adds to user path as well
18
Hosting – IIS or Kestrel or…
Kestrel is a .NET based cross-platform web server Built on top of LibUV Cross-plat C library Asynchronous IO & Networking Used by NodeJS as well On Linux and Mac Kestrel: command line with DNX On Windows Kestrel: command line with DNX IIS: bit different than what we get used to so far not in-proc in IIS, ASP.NET runs in its own process (dnx.exe) IIS creates process, forwards request to it etc.
19
How to get started? get.asp.net Windows OS X 1.) Install VS2015
2.) Download the ASP.NET 5 RC1 installer – runtime + tooling in a single MSI 3.) dnvm upgrade 4.) File – New Project… OS X 1.) Get DNVM with CURL 2.) If you’d like to use Mono install it with Homebrew 2.) Get DNX for CoreCLR or Mono curl -sSL | DNX_BRANCH=dev sh && source ~/.dnx/dnvm/dnvm.sh dnvm upgrade -r coreclr
20
New Project Structure wwwroot – JS / CSS / HTML
References - .NET assemblies Dependencies – NPM / Bower packages Multi-Targeting global.json project.json .xproj, .sln appsettings.json
21
global.json projects [ ] – which folders contain source code?
sdk { } – which DNX version is targeted?
22
project.json wwwroot location Application version .NET Dependencies
Commands Target frameworks Exclusions Scripts to run
23
project.json – project.lock.json
Not for humans Project.lock.json – flatten dependencies, write means recalc, just like Gemfile.lock
24
Framework multi-targeting
JSON object in project.json With .NET Core frameworks are just folders on disk C:\users\gkovacs\.dnx\runtimes\dnx-coreclr-win-x rc1-final Compile for both .NET and .NET Core from the same project type in one step Separate dependencies for each target FW in Solution Explorer Different icons for NuGet / binary / FW assemblies
25
Commands Support for command line tooling
Supports simple invocation of a managed entry point Can be invoked with DNX Example: Start Kestrel Web server When packaged, Commands are made into PS / bash scripts
26
DNU – .NET Development Utility
Build a project – produce assemblies from source Package feed configuration (nuget.org, MyGet, VSO,…) List dependencies of a given project Create a NuGet package from a folder Publish Restore packages Wrap csproj -> project.json
27
Dependency management - NuGet
NuGet everywhere – each project is made into a NuGet and referenced like that View the transitive dependencies in a hierarchical view Same JSON property whether it be NuGet, assembly ref, source from an open source project whatever else “I have a list of deps, but I don’t care where they come from”
28
Dependency mgmt. – Bower & NPM
29
Application Startup Convention based entry point in Startup class’s Configure() method Configure() ConfigureServices()
30
Startup.Configure() Injected through the DI container
31
HTTP request pipeline – 1. Overview
HTTP request pipeline is fully customizable Middleware concept – you define your own events
32
HTTP request pipeline – 2. Simple example
Two very simple example for middlewares Use() and Run() Run accepts a delegate with no “next” reference in its signature. Becomes always the last one in the pipeline
33
HTTP request pipeline – 3. Customization
Customizable to the last bit – “Only get what you’ve paid for” Static File handling (yes, even that!) Dev time: BrowserLink Dev time: Exception & DB error pages How does it come to IIS? How does it relate to OWIN? Migration is supported (Katana interface is similar, IAppBuilder) Has OWIN compatibility, but ASP.NET 5 itself is NOT built on top of OWIN
34
Configuration Where is my web.config?
A Code-based configuration approach ConfigurationBuilder class .AddJsonFile() .AddEnvironmentVariables() Environmental awareness – built-in support for multiple environments
35
Dependency Injection ASP.NET 5 has built-in DI support for basic scenarios Core to ASP.NET, own FW’s like MVC use DI to get their components can replace with your custom easily Typically through extension methods in Startup.ConfigureServices(IServiceCollection services) Transient – new instance each time when requested (light-weight & stateless) Scoped – once per request Singleton – created on first request, then same instance is served in subsequent requests Instance – add a single instance, non lazy loaded compared to Singleton
36
MVC 6 - Brief A fusion of Web API and MVC
Using the same routing / filters / dependency injection… Follows the ASP.NET 5 philosophy Just step in Startup.Configure()
37
MVC 6 – Tag Helpers Razor (no CSS IntelliSense as we’re in C#) Tag Helpers Same equivalents of HTML Helpers Using HTML Attributes instead of C#
38
EF 7 – Brief Light-weight & extensible Supports different OS’es
Supports different DB technologies (e.g.: SQLite on OS X) Not only for relational DBs: Azure Table Storage & Redis Removing: EDMX, ObjectContext, MEST, very complex type <-> table mappings
39
Performance github.com/aspnet/benchmarks TechEmpowered
PlainText benchmark Sends back “Hello World” Goes through the HTTP pipeline (routing, etc.) (ASP).NET perf on Win vs Linux?
40
Deployment – Visual Studio tooling
File System Docker on a Linux VM: right click, Publish Azure Web App: right click, Publish
41
Deployment – Visual Studio tooling
Content to be published Invoke MSDeploy
42
Tools for Cross-Platform Development
VSCode is always a fine option on OS X & Linux No .xproj, .sln files required – completely decoupled from Visual Studio OmniSharp -> not only in VSCode but Sublime, Emacs… Determines runtime based on global.json Parses discovered DNX projects to provide code editor services
43
Tools for Cross-Platform Development
44
X-Plat is not easy Max path restriction Console.Color ???
Eventing – no ETW other places, some analogue is found, usually OS es have same needs but implemented differently – same exp is provided SqlClient and ADO.NET had lots of native dependencies on Windows, built ~10 years ago. Porting was a P.I.T.A. SqlClient almost completely rewritten in C# to support other OSes Hard to achieve a dev experience like VS on other OS’es Exception handling / (async) debugging / interactive windows / live perf view / BrowserLink / designers… (solved)
45
Resources Try it at home - get.asp.net Books – not yet
Read the docs - docs.asp.net Channel9, MVA courses… Check the source github.com/aspnet github.com/dotnet/coreclr github.com/dotnet/corefx Community Standups – live.asp.net
46
Q&A
47
https://pixelastic.github.io/pokemonorbigdata/
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.