Contenu connexe Similaire à Introduction to ASP.NET Core (20) Plus de Avanade Nederland (20) Introduction to ASP.NET Core1. ©2016 Avanade Inc. All Rights Reserved.
Masters in Microsoft
(ASP).NET Core
Sjoerd van der Meer & Albert Sluijter
12-5-2016
3. ©2016 Avanade Inc. All Rights Reserved.
• History and introduction to .NET Core
• .NET Platform Standard
• .NET Command Line Interface
• Compilers
• Break
• ASP.NET Core Pipeline
• ASP.NET Core MVC
• ASP.NET Core To production
• ASP.NET Core Future
Agenda
4. ©2016 Avanade Inc. All Rights Reserved.
• .NET framework becomes bigger and bigger
• ASP.NET, including MVC, tightly coupled to the framework
• Difficult to keep up the release cycle
History (ASP).NET
2002 2003 2004 2005 2006 2007 … 2013 2014 2015
1.0
16 Jan
2.0
7 Nov
Core RC1
18 Nov
4.6
20 Jul
4.5.1
17 Okt
5. ©2016 Avanade Inc. All Rights Reserved.
Fragmentation of .NET
• Multiple, fragmented versions of .NET for different platforms
• There’s a different runtime, framework and application model
• Different platforms are always going to have different features and capabilities
Windows
Desktop
App Model
Framework
Runtime
Windows Store
App Model
Framework
Runtime
Windows
Phone
App Model
Framework
Runtime
ASP.NET 4
App Model
Framework
Runtime
6. ©2016 Avanade Inc. All Rights Reserved.
Portable Class Library (PCL)
.NET Framework
Windows Phone
Windows Universal
8. ©2016 Avanade Inc. All Rights Reserved.
.NET Platform Standard
Why? To provide a more concrete guarantee of binary portability to future .NET-
capable platforms with an easier-to-understand platform versioning plan
.NET Platform Standard netstandard 1 1.1 1.2 1.3 1.4 1.5
.NET Core netcoreapp → → → → → 1
.NET Framework net → → → → → 4.6.2
→ → → → 4.6.1
→ → → 4.6
→ → 4.5.2
→ → 4.5.1
→ 4.5
Universal Windows Platform uap → → → → 10
Windows win → → 8.1
→ 8
Windows Phone wpa → → 8.1
Windows Phone Silverlight wp 8.1
8
Mono/Xamarin Platforms → → → → → *
Mono → → *
10. ©2016 Avanade Inc. All Rights Reserved.
Compilers
.NET Native Compiler
AOT
.NET Assemblies (IL)
RyuJIT
Roslyn Compiler
Native
JIT
CoreCLR CoreRT
Single native file
11. ©2016 Avanade Inc. All Rights Reserved.
• Lightweight
• Modular
• Cross platform
• No machine wide installation
• Run multiple versions in parallel
• Faster (package based) release cycles
Why .NET Core
12. ©2016 Avanade Inc. All Rights Reserved.
.NET framework Mono .NET Core
Machine wide Machine wide Per app
Existing code Existing code New code
Many types Many types Limited types
Windows only Cross-platform Cross-platform
Framework choices
13. ©2016 Avanade Inc. All Rights Reserved.
• ASP.NET 4.6 is the more mature platform.
• ASP.NET Core 1.0 is a 1.0 release that includes Web API and MVC
but doesn't yet have SignalR or Web Pages.
• It doesn't yet support VB or F#. It might have these subsystems
some day.
When use .NET Core
14. ©2016 Avanade Inc. All Rights Reserved.
.NET CLI
•Command-line first approach
•Replaces DNX, DNU and DNVM
•dotnet new
•dotnet restore
•dotnet run
•dotnet build
•dotnet publish
15. ©2016 Avanade Inc. All Rights Reserved.©2016 Avanade Inc. All Rights Reserved.
15
Demo .NET CLI
16. ©2016 Avanade Inc. All Rights Reserved.
• Open source Web server for ASP.NET
based on libuv (also used by NodeJS)
• It is fast and production ready.
• It is not a fully featured web server.
• It is recommended that you run it behind
a more fully featured webserver like IIS on
Windows or NGNIX on Linux.
• It is run behind IIS using the ASP.NET Core
Module (native IIS module).
• Maps a HTTP Request to the HttpContext.
Kestrel
17. ©2016 Avanade Inc. All Rights Reserved.
Kestrel performance
0
500000
1000000
1500000
2000000
2500000
3000000
ASP.NET 4.6 ASP.NET 5 NodeJS ASP.NET 5 Scala - Plain Netty
IIS WebListener Node Kestrel Plain Netty
Max of RPS Avg
1 - x64 1 - x86 16 - x64 16 - x86
18. ©2016 Avanade Inc. All Rights Reserved.©2016 Avanade Inc. All Rights Reserved.
18
BREAK
19. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Core web application
Request
Response
Application
Console.WriteLine(“Hello world!”)
How to make a webapplication from a console app?
20. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Core web application
Request
Response
Application
Add Kestrel Server
Binds to a port and transforms request for Asp.net core
Kestrel
21. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Core web application
Request
Response
Kestrel passes the request to a middleware pipeline
Kestrel
Middleware
Middleware
Middleware
Middleware
22. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Core web application
Request
Response
Hello web
Kestrel
Helloworld
23. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Core web application
Middleware pipeline is method chaining
Kestrel
Middleware
Middleware
Middleware
next()
return
return
next()
return
Request
Response
25. ©2016 Avanade Inc. All Rights Reserved.©2016 Avanade Inc. All Rights Reserved.
25
Let’s play with the middleware
pipeline
26. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Core web application
Kestrel server does nothing by default
Cookie
authentication
Static Files
Database error
page
Asp.net MVC
Facebook
authentication
Developer
Exception page
Examples of middleware
Add features as middleware!
Runtime info page
Status Code pages
27. ©2016 Avanade Inc. All Rights Reserved.
Web application framework
Does: Routing – Modelbinding – Templating
Goals:
Seperation of concerns
Patterns based
Full control over output (html/json/xml)
TDD friendly
Asp.net MVC 6
ModelView
Controller
28. ©2016 Avanade Inc. All Rights Reserved.
Asp.net Asp.net core
Asp.net MVC 6
MVC 5
WebApi 2
System.Web
Owin
Asp.net Core
{json} & <xml/>
<html/>
MVC 6
<html/>{json} & <xml/>
git merge
29. ©2016 Avanade Inc. All Rights Reserved.©2016 Avanade Inc. All Rights Reserved.
29
MVC Demo
Yo maann! Before you
start all over again
30. ©2016 Avanade Inc. All Rights Reserved.
• Scaffolding tool
• npm install --global yo
• Generates
• Projects
• Classes
• Files
• Uses generators
• npm install --global generator-aspnet
Yeoman
Yo!
31. ©2016 Avanade Inc. All Rights Reserved.©2016 Avanade Inc. All Rights Reserved.
31
yo aspnet
32. ©2016 Avanade Inc. All Rights Reserved.
Host my app
dotnet run?
Multiple apps on one server?
(only one port 80)
And SSL?
Windows authentication?
Going to production
Request
Response
My Epic Web
Application
Kestrel
33. ©2016 Avanade Inc. All Rights Reserved.
Run it with a
reverse proxy
• IIS
• Install ASP.NET Core
Module first
• nginx
• Apache
Going to production
Request
Response
My Epic Web
Application
Kestrel
IIS–nginx–apache
:80/:443
:5000
34. ©2016 Avanade Inc. All Rights Reserved.©2016 Avanade Inc. All Rights Reserved.
34
dotnet publish
35. ©2016 Avanade Inc. All Rights Reserved.
Asp.net core future
Docker Nano Server (size 550MB)
Microservices
Azure service fabric
Raspberry PI (ARM)
36. ©2016 Avanade Inc. All Rights Reserved.
Timeline
Today
16 May 2016
June - July
July - September
End of 2016
.net core & Asp.net core RC2-final
Tooling preview1 (Visual studio & dotnet-cli)
.net core & Asp.net core RTM
Tooling still in preview
Asp.net core SignalR
Tooling RTM
Expecting .net core & asp.net core 1.1
.net core & Asp.net core RC2 almost final
37. ©2016 Avanade Inc. All Rights Reserved.
Starting point for .NET
dot.net/
Asp.net core docs
docs.asp.net/
All open source on Github
• Github.com/dotnet/
• Github.com/aspnet/
• Github.com/microsoft/
Get Code it’s awesome
(and open source)
code.visualstudio.com/
Omnisharp intellisense for editors
omnisharp.net/
github.com/omnisharp
Getting started