Presentation for Stichting DotNed in 2015:
Microsoft neemt ASP.NET op de schop. Het web applicatie framework uit .NET 1.0 wordt grotendeels herschreven om te voldoen aan de eisen die men tegenwoordig stelt aan het realiseren van een moderne web applicatie. Deze sessie kijken we naar de nieuwe opzet van ASP.NET. We zien hoe Microsoft daarmee een cloud geoptimaliseerd, cross-platform framework creeert, dat zij zelf sneller kunnen laten evolueren door kortere release cycles. Dit alles betekent wel dat ASP.NET anders is geworden. In deze sessie leer je daarom ook wat er is veranderd, hoe je aan de slag gaat en waarom ASP.NET vNext een revolutionaire stap is in Microsoft's framework.
3. Agenda
• .NET and ASP.NET vNext architecture
• Running vNext applications
• Middleware
• MVC 6
• Visual Studio 2015 support
• Client-side web application development
• Summary
• Questions and Answers
4. Next gen JIT (“RyuJIT”)
SIMD (Data Parallelization)
Runtime Compilers
.NET Compiler Platform (“Roslyn”)
Languages innovation
BCL and PCL
Entity Framework
Libraries
5. ASP.NET vNext and the Modern Web
Choose your editors
and tools
Open Source
with contributions
Cross-Platform
Seamless transition
from on-premises to cloud
Faster development cycleTotally modular
Fast
6. Tenets from ASP.NET team
Command-line
first
• Facilitate cross-
platform
• Visual Studio for
premium
experience
Symmetry
• Between command-
line and vs
• Between server and
cloud
• It just works by
default in the cloud
and on-premises
Open source
• All code visible
(even during
development)
• Contributions
Light-weight and
Pay-as-you-go
• Only include what
you use
7. From monolith to pebbles
ASP.NET 4.5 (in CLR 4.5.2) ASP.NET 5.0
ASP.NET 5.0
9. .NET Framework vNext
Full .NET CLR
• Entire API set in machine wide
install at 200 MB
• Updated with OS
• Ecosystem of existing packages
• Backward compatibility
• Default for
Visual Studio 2015 projects
Cloud Optimized CLR
• Lean and modular runtime
• Optimized for server
• Small memory footprint
• Libraries in NuGet packages
• Framework deployed with app
• Different versions can run side-
by-side
• 11 MB
Mono
• Cross-Platform runtime for
Linux and Mac OS X
• Together with Mono
community
ASP.NET 5.0 ASP.NET 5.0 ASP.NET 5.0
10. vNext technology stack
Host
Mac OS X
Linux
Self
Hosted
“Helios”
IIS
IIS Native Module IIS Native Module
.NET FX CLRCore CLR Mono CLR
.NET Base Class Library
ASP.NET vNext
Windows
Cloud/Server optimized
12. .NET Compiler Platform (“Roslyn”)
TO
API: open platform
Rich IDE experiences/refactoring
Code analysis
Custom diagnostics
Open Source compilers
.NET Compilers Platform (a.k.a. ROSLYN)
C#, VB
Source code
.exe/.dil
IL assemblies
Open platform
for developers
FROM
Isolated/closed compilers
Hard to extend dev experience
C#, VB
Source code
.exe/.dil
IL assemblies
Established .NET compilers
14. New project system
• Independent of Visual Studio
• JSON files instead of VS artefacts
• No more .csproj
• Every file is relevant
• Unless stated otherwise
• Different folder structure
• Build for multiple target frameworks
15. Project K – K galore
K: K for Katana
• Bootstrapper for KLR
• New name for KRE (?)
KRE: Runtime
Environment
• Home of runtimes and
packages
KVM: Version Manager
• Install or upgrade KRE
versions
• List available versions
• Switch default
KPM: Package manager
• Restore packages
• Pack and build project
• List dependencies
16. Simplify dependency management
• NuGet packages are unit
of reference
• Not assemblies
• Projects can reference
NuGet packages
and vice versa
20. Startup
1. Host loads correct runtime
2. NuGet packages and assemblies get loaded
3. Application code is loaded and startup sequence inside app runs
• Configure
• ConfigureServices
21. Configuration
• Multiple configuration sources
• JSON, XML or INI files
• Environment variables
• Command-line arguments (console applications)
• New hierarchical syntax with colons (:)
Configuration config = new Configuration();
config
.AddIniFile(@"App_Datasetting.ini")
.AddEnvironmentVariables();
string conn = config.Get("database:connectionString");
22. Dependency Injection
• DI is core part of runtime
• Built-in DI for configuration and services
• Default minimalistic version available
• Wire up your own favorite IoC container ...
• Autofac, Ninject, StructureMap, Unity, Castle Windsor
public void ConfigureServices(IServiceCollection services)
{
// Add EF services to the services container.
services.AddEntityFramework(Configuration)
.AddSqlServer()
.AddDbContext<ApplicationDbContext>();
23. Other features
• Templates and scaffolding
• k gen
• Razor instead of T4 templates in ASP.NET vNext
• Server Features
24. Middleware conceptually
Middleware stack
• Static files
• Security, authentication, CORS
• Diagnostics, logging
• Other cross-cutting concerns
Host process and server
Application and framework
RequestDelegate delegate Task
RequestDelegate(HttpContext context);
25. • Pipeline of components between server and application
• Connected through RequestDelegate
• Constructed at startup of app
vNext compatible
application frameworks
Middleware architecture
Stacking pipeline parts
Host
Middleware
pipeline
26. public void Configure(IApplicationBuilder app)
{
app.Map("/Nancy",
builder =>
{ builder.Use<LogMiddleware>();
builder.RunNancyFx();
});
app.UseCors();
app.UseMvc(cfg);
Use, Map and Run
app.UseErrorPage();
27. Custom middleware
• All middleware has same
purpose
• Run Func implementation of itself
• Invoke next component in pipeline
• Use initialization pattern
• Options object
• Extension method on
IApplicationBuilder
Create your own middleware components
Middleware
type
• POCO class
• Implement Invoke
Owin
Middleware
• Base class
• Implement Invoke
Funcy
Delegate
• Func<
RequestDelegate,
RequestDelegate>
Middleware
Instance
• Any object instance
of the previous
• IoC
28. Assembly Neutral Interfaces
• Allows an interface's identity to not be tied to its assembly
• Interface used as a contract
• No requirement on shared binary asset (compile-time and run-time)
• Interfaces must be identical
• Exact same types and marked with [AssemblyNeutral]
[AssemblyNeutral]
public interface ILogger
{
void Log(string message);
}
30. ASP.NET MVC 6
• One set of concepts – remove duplication
• Web UI and APIs
• Smooth transition from Web Pages to MVC
• Built DI first
• Run on IIS or self-host
• Based on new request pipeline in ASP.NET vNext
• Runs cloud-optimized
31. New and improved (some details)
• Classes of Controller and ApiController merged
• No required base class for controller
• POCO controller classes
• REST and classic MVC style actions
• Dependency Injection everywhere
• [Activate], [FromServices]
• Constructors
• ViewComponents
• Route tokens [controller] and [action]
32. Project structure
• Visual Studio plays nicely with other editors
• All files included by default
• VS specific files .kproj when needed
• No files written to disk
• Combined IntelliSense
• Config improvements
33. Bower, grunt and gulp in Visual Studio
• Task Runner Explorer
Package managers for client
and server
Task Runners
34. Getting started
• Main starting point at http://www.asp.net/vnext
• Open sourced at
• http://github.com/aspnet
• http://github.com/dotnet/home
• Help and feedback
• JabbR: https://jabbr.net/#rooms/aspnetvnext
• ASP.NET vNext forums: http://forums.asp.net/
• Nightly build for the adventurous
• http://github.com/aspnet/home for instructions on how to do bleeding edge