Welcome
Subscribe to the Lunch&Learn wiki page to stay up to date with next events!
Preview on
.Net
Asp.Net
Visual Studio
vNext
Topics
- A look out the window
- The future of .Net
- Asp.Net 5 (aka vNext)
- Hands on
A look out the window
- Ruby on Rails + gems
- Node.js + NPM
Why they matter
- Very high-level languages
- Smooth dev workflow
- Package managers
- Huge influence on current and future Asp.Net development
Huge open source communities -
Comparison on # of published modules
Iper productive
var express = require('express');
var app = express();
var fs = require('fs');
// Code based configuration
app.configure(function(){
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.get('/', function(req, res) {
res.setHeader('Content-Type', 'text/html');
fs.createReadStream(__dirname + '/index.html').pipe(res);
});
var port = process.env.PORT || 3000;
app.listen(port);
console.log("Express server listening on port %d in %s mode", port, app.settings.env);
Iper productive /2
{
"name": "ShopWithMe",
"description": "ShopWithMe allows you to create and share your shopping lists with your friends to collaboratively edit them",
"version": "0.1.0",
"private": false,
"dependencies": {
"express": "3.x",
"mongoose": "3.5.x",
"winston": "0.6.x",
"moment": "2.1.x",
"request": "~2.27.0"
},
"devDependencies": {
"supertest": "0.5.x",
"mocha": "1.8.x",
"should": "1.2.x",
"grunt": "~0.4.0",
"grunt-contrib-jshint": "~0.6.0",
"grunt-contrib-concat": "~0.1.1",
"grunt-contrib-uglify": "~0.1.0",
"grunt-contrib-watch": "~0.1.4",
"grunt-cafe-mocha": "~0.1.3",
"grunt-mocha-cov": "0.0.7"
},
"scripts": {
"test": "make test",
"blanket": {
"pattern": [
"handlers",
"models"
]
}
}
}
The future of .Net
Open source all the things!
A brand new runtime
.Net Core 5
What is .Net Core 5
- An alternative to the full .Net framework
- Modular development stack delivered via Nuget
- Application-local vs
Machine-wide framework
- Application-local vs
- Basis of Asp.Net 5
- Foundation of all future .Net platforms
- Moonshot?
- Risk of fragmentation?
.Net core platform
architectural diagram
.Net core platform
architectural diagram
Main features
- Smaller API surface
- Lighter runtime
- 11 MB vs 200 MB full .Net framework
- Higher performances
- Supports full side by side
- The runtime is deployed alongside the app
One more thing...
Multiplatform
Today vs tomorrow
The open .Net ecosystem
Asp.Net 5
- Open source and accepting contributions
- Lean and composable stack
- Can target full .Net CLR but to get most benefits, target .Net Core 5
- Based on OWIN
- Drop-in support for old Asp.Net based projects
What's new
But first...
New HTTP request pipeline
Unlearn
- System.Web (not even available on CoreCLR)
- HTTP Modules
- HTTP Handlers
Middleware
functions instead!
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.Use(
new Func<RequestDelegate, RequestDelegate>(
MyMiddleware));
// Other middleware components go here
}
RequestDelegate MyMiddleware(
RequestDelegate next)
{
RequestDelegate rd = (HttpContext ctxt) =>
{
ctxt.Response.WriteAsync(
"Hello, ASP.NET 5");
return next(ctxt);
};
return rd;
}
}
Unified programming model
MVC + WebAPI
=
MVC 6
New project system
- global.json contains solution-level settings, and enables project-to-project references.
- src folder
- wwwroot: static content
New Project.json file
replaces
*.csproj and packages.config files
It doesn't contain the list of files inside the project!
No more merge conflicts!
Project.json (looks familiar...)
{
"dependencies": {
"EntityFramework.SqlServer": "7.0.0-beta1",
"Microsoft.AspNet.Mvc": "6.0.0-beta1",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta1",
"Microsoft.AspNet.Security.Cookies": "1.0.0-beta1",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta1",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta1",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta1",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta1",
"Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta1"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"aspnet50": { },
"aspnetcore50": { }
}
}
New configuration system
-
Everything is code based
-
Unlearn
-
Web.config (based on System.web)
- cannot restart anymore AppDomain by modifying Web.config
- configuration transformations
- Global.asax (was based on old Http pipeline)
-
Web.config (based on System.web)
-
Unlearn
- Support multiple configuration sources
Startup.cs
public Startup()
{
Configuration = new Configuration()
.AddJsonFile("config.json")
//.AddIniFile("test.ini") Multiple sources
.AddEnvironmentVariables();
}
public void Configure(IApplicationBuilder app)
{
var day = Configuration.Get("demo:day");
var people = Configuration.Get<int>("demo:people");
var cool = Configuration.Get<bool>("demo:areTheyCool");
var tags = Configuration.Get("demo:tags").Split(';');
app.UseMvc(routes =>
{
// Classic routing code
});
}
New dependency management system
- Supports true side by side .Net versions (CoreCLR)
- dependencies defined into deployment package
- Unlearn GAC!
-
Unlearn assembly references:
- Manage dependencies by referencing NuGet packages
No-compile
refresh-and-go development process
Courtesy of Roslyn
Built in dependency injection
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseServices(services =>
{
// Set up the dependencies
services.AddTransient<IFooService, FooService>();
services.AddSingleton<IFooRepository, FooRepository>();
});
}
}
Demo time
Credits
- Philip W Asp.Net 5 presentation
- Scott Hanselman for the open .Net arch diagram
- Damien Edwards for the "Today vs Tomorrow" slide
A look into the future of .Net
By Valerio Gheri
A look into the future of .Net
- 2,212