SlideShare a Scribd company logo
ASP.NET Core: Reimagining Web
Application Development in .NET
Ido Flatow
Senior Architect
Microsoft MVP & RD
Sela Group
@idoflatow
Agenda
• ASP.NET History
• ASP.NET Core 1.0 and .NET
• ASP.NET Core 1.0 Features
• ASP.NET Core MVC
ASP.NET, THEN AND NOW
History of ASP (20 years)
• 1996 - Active Server Pages (ASP)
• 2002 – ASP.NET
• 2005 – ASP.NET 2
• 2008 – ASP.NET MVC
• 2012 – ASP.NET Web API
• 2014 – ASP.NET vNext
– 2015 – ASP.NET 5 RC1
– 2016 – ASP.NET Core 1.0 (June 27th, 2016)
Problems with ASP.NET Architecture
• Limited hosting possibilities (IIS only)
• Dependency on IIS environment (System.Web)
• Web evolves faster than the .NET Framework
• Requires full-blown .NET Framework
• Resource intensive and not web-friendly
• Hard to optimize for lightweight high-performance apps
• Not completely cloud-optimized
Introducing ASP.NET Core 1.0
(Tools in Preview 2)
OS
.NET CLR
ASP.NET
MVC
(UI + API)
Host
Self-HostedIIS
.NET Core CLR
Middleware
What is Tooling?
• Everything that is part of the framework
• Command line tools
– dotnet CLI
• Project tools
– ASP.NET templates
– xproj / csproj
• Visual Studio tools
– Configuration IntelliSense
– Debugger support
Two Runtimes
• .NET Full Framework (4.6)
– Not going away…
– Windows hosting with full .NET APIs
• .NET Core 1.0
– Subset of the full framework
• No Windows Forms, WPF, Silverlight
• No System.Web (WebForms)
– Implemented as set of NuGet packages
– Cross-platform and Nano server support
GETTING TO KNOW ASP.NET
CORE
ASP.NET Core Features
• Flexible and cross-platform runtime
• Modular HTTP request pipeline
• Unifying MVC, Web API, and Web Pages
• Side-by-side versioning with .NET Core
• Built-in Dependency Injection
• Self-host and IIS-hosted (sort of…)
• Open source on GitHub
CREATING A NEW ASP.NET
CORE PROJECT
Demo
Solution and Projects
• global.json
Project references (in addition to the .sln)
• wwwroot
Root for static content (html, css, js, images, etc…)
• Program.cs
ASP.NET hosting libraries. This is where it all starts
• project.json
References, compiler settings, tooling (replaces web.config and
packages.config)
• Startup.cs
DI and pipeline configuration
(replaces global.asax and configuration code)
PROJECT.JSON, STARTUP.CS
AND PROGRAM.CS
Demo
ASP.NET Core Middlewares
• Improved HTTP performance
– New lean and fast HTTP request pipeline
– You choose what to use in your application
– By registering middlewares
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
app.UseExceptionHandler("/Home/Error");
app.UseStaticFiles();
app.UseIdentity();
app.UseMvc(routes => ...)
}
Where’s the AppSettings?
• Not relying on web.config anymore
• New configuration system based on key/value pairs:
– JSON files
– INI files
– XML files
– Environment variables
• Configuration can come from multiple resources
– Last resource wins
Loading Settings
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddXmlFile("appsettings.xml", optional:true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json",true);
if (env.IsDevelopment())
{
builder.AddUserSecrets();
}
builder.AddEnvironmentVariables();
IConfigurationRoot Configuration = builder.Build();
...
string connString = Configuration["Data:Default:ConnectionString"];
Dependency Injection
• ASP.NET Core is DI-friendly
• Basic DI container available throughout the stack
• BYOC is also supported (already implemented for Autofac, Dryloc,
StructureMap, etc.)
• Out-of-the-box container supports:
– Singleton / Instance – single instance
– Transient – new instance each time
– Scoped – new instance per request (HTTP context)
• https://github.com/aspnet/DependencyInjection
DI with Controllers
public class ProductsController : Controller
{
private readonly IProductsRepository _repository;
public ProductsController(IProductsRepository repository)
{
this._repository = repository;
}
public IActionResult Index()
{
var products = _repository.GetAllProducts();
return View(products);
}
}
services.AddTransient<IProductsRepository, DefaultProductsRepository>();
Logging
• ASP.NET Core has built-in support for logging
• Uses the built-in DI to get a logger instance
• Standard logger outputs: category, log level, event Id, and message
• Built-in loggers for:
– Console (hosting from cmd/terminal)
– TraceSource (good old System.Diagnostics)
– Debug (Visual Studio output window)
• Custom loggers are also available (log4net, serilog, elmah, etc.)
• https://github.com/aspnet/Logging
Logging with Controllers
public class TodoController : Controller
{
private readonly ITodoRepository _todoRepository;
private readonly ILogger<TodoController> _logger;
private const int LIST_ITEMS = 1001;
public TodoController(ITodoRepository todoRepo, ILogger<TodoController> logger)
{
_todoRepository = todoRepo;
_logger = logger;
}
[HttpGet]
public IEnumerable<TodoItem> GetAll()
{
_logger.LogInformation(LIST_ITEMS, "Listing all items");
EnsureItems();
return _todoRepository.GetAll();
}
}
The dotnet CLI
• Cross-platform command line toolchain
• Written in .NET Core
• External commands
• https://github.com/dotnet/cli
dotnet new
dotnet restore
dotnet build --output /stuff
dotnet /stuff/new.dll
dotnet publish
dotnet ef
dotnet razor-tooling
Dotnet aspnet-codegenerator
Hosting ASP.NET Core
• ASP.NET Core 1.0 is a stand-alone application
– Uses Kestrel HTTP server (based on libuv, as with node.js)
• Self-hosting with .NET Core
– Compiled into a .dll file, hosted by the dotnet CLI
• Self-hosting with .NET 4.6
– Compiles into an .exe file
– Kestrel or the WebListener server (Windows HTTP.sys)
• IIS-hosted (.NET Core / .NET 4.6)
– IIS uses the ASP.NET Core Module to start the self-hosted app
– ASP.NET Core template generates the required web.config
– Starts either dotnet webapp1.dll or webapp.exe
• https://docs.asp.net/en/latest/hosting/aspnet-core-module.html
CROSS-PLATFORM
ASP.NET CORE
Demo
ASP.NET CORE MVC
ASP.NET <= 4.6 Frameworks
ASP.NET Core with MVC
ASP.NET Core MVC
• No more duplication - one set of concepts
• Used for creating both UI and API
• Based on the new ASP.NET Core pipeline
• Supports .NET Core
• Built DI first
• Runs on IIS or self-host
• New features in controllers and views
Getting Started with MVC
• Project.json
• Startup.cs
"dependencies": {
"Microsoft.AspNet.Server.Kestrel": "1.0.0",
// Add this:
"Microsoft.AspNet.Mvc": "1.0.0"
}
// Register MVC default services for DI
services.AddMvc();
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
Web API Configuration
• Route configuration -> attribute-based routing
• Message handlers -> middleware pipeline
• Filters and Formatters -> startup.cs
services.AddMvc()
.AddXmlDataContractSerializerFormatters()
.AddMvcOptions(options =>
{
options.Filters.Add(new ValidatorFilterAttribute());
})
.AddJsonOptions(jsonOptions =>
{
jsonOptions.SerializerSettings.Formatting = Formatting.Indented;
});
Controllers – Two in One
• UI – same as with MVC 5
• API – similar, but different
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
}
[Route("api/[controller]")]
public class ProductsController : Controller
{
[HttpGet("{id:int}")]
public Product GetProduct(int id)
{
return new Product() { ID = id };
}
}
Actions – IActionResult
[HttpGet("{id:int}", Name = "GetByIdRoute")]
public IActionResult GetById (int id)
{
var item = _items.FirstOrDefault(x => x.Id == id);
if (item == null) { return NotFound(); }
return new ObjectResult(item);
}
[HttpPost]
public IActionResult CreateTodoItem([FromBody] TodoItem item)
{
_items.Add(item);
return CreatedAtRoute(
"GetByIdRoute", new { id = item.Id }, item);
}
Showing Some UI for Your API
• Swagger - a JSON-based service description framework
• Create a Swagger endpoint using Swashbuckle.SwaggerGen
– Browse to /swagger/v1/swagger.json
• Host a built-in UI for testing APIs with Swashbuckle.SwaggerUi
– Browse to /swagger/ui
"dependencies": {
"Swashbuckle.SwaggerGen": "6.0.0-beta901",
"Swashbuckle.SwaggerUi": "6.0.0-beta901"
}
services.AddSwaggerGen();
app.UseSwagger();
app.UseSwaggerUi();
Enough with controllers,
What about views?
Oh, right!
Injecting Services to Views
• Preferable than using static classes/methods
• Use interfaces instead of concrete types
• Register in IoC using different lifecycles
public class CatalogService : ICatalogService
{
public async Task<int> GetTotalProducts() {...} // From ICatalogService
}
@inject MyApp.Services.ICatalogService Catalog
<html>
<body>
<h3>Number of products in the catalog</h3>
@await Catalog.GetTotalProducts()
</body>
</html>
services.AddTransient<ICatalogService, CatalogService>();
Flushing Content with Razor
• In ASP.NET <= 5, browser had to wait until Razor
rendered the entire page
• Razor now supports flushing, causing HTML to get
chunked (streamed)
– @await FlushAsync()
• Not supported when rendering layout sections
Last, but not Least, Tag Helpers
• Tag helpers are an alternative to HTML helpers
• Tag helpers look like regular HTML elements
• Instead of doing this:
• Do this:
• It’s the return of Web Controls, NOOOOOO!!!
@Html.ActionLink("Click me", "AnotherAction")
<a asp-action="AnotherAction">Click me</a>
Tag Helpers are not Evil
• Tag Helpers generate markup within their enclosing tag
• Less Razor/HTML mess in the .cshtml file
• Data-attributes style approach
• Use C# to better construct the markup
– Add/remove parts from the inner content
– Generate complex HTML (recursive, nested, …)
– Cache the output
Existing Tag Helpers
• HTML elements
– <a>, <form>, <input>, <label>, <link>, <script>, <select>, <textarea>
• Logical
– <cache>
• Placeholders
– ValidationSummary (<div>), ValidationMessage (<span>)
• You can create your own Tag Helpers
• Check out the source for reference
https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNetCore.Mvc.TagHelpers
Key Improvements in ASP.NET Core
• Totally modular - Everything is a package
• Lightweight - you use minimum set of modules
• Faster startup, lower memory footprint
• Can be deployed side-by-side with .NET Core
• Cross platform - can be hosted anywhere
• Better developer experience – DI and one MVC
• Everything is open-sourced
Key Improvements in ASP.NET Core
Get Started with ASP.NET Core
• Install Visual Studio 2015 / Visual Studio Code
• Walkthroughs and samples at http://www.asp.net/core
• Documentation at http://docs.asp.net/en/latest
• Get the code from http://github.com/aspnet
• Read blogs at http://blogs.msdn.com/b/webdev
• @IdoFlatow // idof@sela.co.il // http://www.idoflatow.net/downloads

More Related Content

What's hot

Owin and katana
Owin and katanaOwin and katana
Owin and katana
Udaiappa Ramachandran
 
Owin and Katana
Owin and KatanaOwin and Katana
Owin and Katana
Ugo Lattanzi
 
Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6
Ido Flatow
 
Angular Owin Katana TypeScript
Angular Owin Katana TypeScriptAngular Owin Katana TypeScript
Angular Owin Katana TypeScript
Justin Wendlandt
 
OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)
Folio3 Software
 
ASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web AppsASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web Apps
Shahed Chowdhuri
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
Simon Funk
 
Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6
Noam Kfir
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
Stacy London
 
JavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersJavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint Developers
Rob Windsor
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
Omri Spector
 
ASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web AppsASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web Apps
Shahed Chowdhuri
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
Rami Sayar
 
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
Sencha
 
Asp.net core 1.0 (Peter Himschoot)
Asp.net core 1.0 (Peter Himschoot)Asp.net core 1.0 (Peter Himschoot)
Asp.net core 1.0 (Peter Himschoot)
Visug
 
"Design First" APIs with Swagger
"Design First" APIs with Swagger"Design First" APIs with Swagger
"Design First" APIs with Swagger
scolestock
 
Fluxible
FluxibleFluxible
Fluxible
Taylor Lovett
 
ASP.NET 5: What's the Big Deal
ASP.NET 5: What's the Big DealASP.NET 5: What's the Big Deal
ASP.NET 5: What's the Big Deal
Jim Duffy
 
Require js training
Require js trainingRequire js training
Require js training
Dr. Awase Khirni Syed
 

What's hot (20)

Owin and katana
Owin and katanaOwin and katana
Owin and katana
 
Owin and Katana
Owin and KatanaOwin and Katana
Owin and Katana
 
Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6
 
Angular Owin Katana TypeScript
Angular Owin Katana TypeScriptAngular Owin Katana TypeScript
Angular Owin Katana TypeScript
 
OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)OWIN (Open Web Interface for .NET)
OWIN (Open Web Interface for .NET)
 
ASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web AppsASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web Apps
 
Laravel introduction
Laravel introductionLaravel introduction
Laravel introduction
 
Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6Angular on ASP.NET MVC 6
Angular on ASP.NET MVC 6
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
JavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersJavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint Developers
 
Building a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring BootBuilding a REST Service in minutes with Spring Boot
Building a REST Service in minutes with Spring Boot
 
ASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web AppsASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web Apps
 
Web a Quebec - JS Debugging
Web a Quebec - JS DebuggingWeb a Quebec - JS Debugging
Web a Quebec - JS Debugging
 
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
SenchaCon 2016: A Look Ahead: Survey Next-Gen Modern Browser APIs - Shikhir S...
 
Asp.net core 1.0 (Peter Himschoot)
Asp.net core 1.0 (Peter Himschoot)Asp.net core 1.0 (Peter Himschoot)
Asp.net core 1.0 (Peter Himschoot)
 
"Design First" APIs with Swagger
"Design First" APIs with Swagger"Design First" APIs with Swagger
"Design First" APIs with Swagger
 
Fluxible
FluxibleFluxible
Fluxible
 
Owin
OwinOwin
Owin
 
ASP.NET 5: What's the Big Deal
ASP.NET 5: What's the Big DealASP.NET 5: What's the Big Deal
ASP.NET 5: What's the Big Deal
 
Require js training
Require js trainingRequire js training
Require js training
 

Viewers also liked

Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
Ido Flatow
 
EF Core (RC2)
EF Core (RC2)EF Core (RC2)
EF Core (RC2)
Ido Flatow
 
What's New in WCF 4.5
What's New in WCF 4.5What's New in WCF 4.5
What's New in WCF 4.5
Ido Flatow
 
The Essentials of Building Cloud-Based Web Apps with Azure
The Essentials of Building Cloud-Based Web Apps with AzureThe Essentials of Building Cloud-Based Web Apps with Azure
The Essentials of Building Cloud-Based Web Apps with Azure
Ido Flatow
 
Debugging the Web with Fiddler
Debugging the Web with FiddlerDebugging the Web with Fiddler
Debugging the Web with Fiddler
Ido Flatow
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
Ido Flatow
 
IIS for Developers
IIS for DevelopersIIS for Developers
IIS for Developers
Ido Flatow
 
Introducing HTTP/2
Introducing HTTP/2Introducing HTTP/2
Introducing HTTP/2
Ido Flatow
 
IaaS vs. PaaS: Windows Azure Compute Solutions
IaaS vs. PaaS: Windows Azure Compute SolutionsIaaS vs. PaaS: Windows Azure Compute Solutions
IaaS vs. PaaS: Windows Azure Compute Solutions
Ido Flatow
 
ASP.NET Core 1.0 Overview
ASP.NET Core 1.0 OverviewASP.NET Core 1.0 Overview
ASP.NET Core 1.0 Overview
Shahed Chowdhuri
 
Advanced WCF Workshop
Advanced WCF WorkshopAdvanced WCF Workshop
Advanced WCF Workshop
Ido Flatow
 
Debugging with Fiddler
Debugging with FiddlerDebugging with Fiddler
Debugging with Fiddler
Ido Flatow
 
What HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For YouWhat HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For You
Mark Nottingham
 
ASP.NET Core 1.0 Overview
ASP.NET Core 1.0 OverviewASP.NET Core 1.0 Overview
ASP.NET Core 1.0 Overview
Shahed Chowdhuri
 
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
Ido Flatow
 
Building IoT and Big Data Solutions on Azure
Building IoT and Big Data Solutions on AzureBuilding IoT and Big Data Solutions on Azure
Building IoT and Big Data Solutions on Azure
Ido Flatow
 
Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015
Ido Flatow
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
Ido Flatow
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
Ido Flatow
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes Everything
Lori MacVittie
 

Viewers also liked (20)

Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
EF Core (RC2)
EF Core (RC2)EF Core (RC2)
EF Core (RC2)
 
What's New in WCF 4.5
What's New in WCF 4.5What's New in WCF 4.5
What's New in WCF 4.5
 
The Essentials of Building Cloud-Based Web Apps with Azure
The Essentials of Building Cloud-Based Web Apps with AzureThe Essentials of Building Cloud-Based Web Apps with Azure
The Essentials of Building Cloud-Based Web Apps with Azure
 
Debugging the Web with Fiddler
Debugging the Web with FiddlerDebugging the Web with Fiddler
Debugging the Web with Fiddler
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
 
IIS for Developers
IIS for DevelopersIIS for Developers
IIS for Developers
 
Introducing HTTP/2
Introducing HTTP/2Introducing HTTP/2
Introducing HTTP/2
 
IaaS vs. PaaS: Windows Azure Compute Solutions
IaaS vs. PaaS: Windows Azure Compute SolutionsIaaS vs. PaaS: Windows Azure Compute Solutions
IaaS vs. PaaS: Windows Azure Compute Solutions
 
ASP.NET Core 1.0 Overview
ASP.NET Core 1.0 OverviewASP.NET Core 1.0 Overview
ASP.NET Core 1.0 Overview
 
Advanced WCF Workshop
Advanced WCF WorkshopAdvanced WCF Workshop
Advanced WCF Workshop
 
Debugging with Fiddler
Debugging with FiddlerDebugging with Fiddler
Debugging with Fiddler
 
What HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For YouWhat HTTP/2.0 Will Do For You
What HTTP/2.0 Will Do For You
 
ASP.NET Core 1.0 Overview
ASP.NET Core 1.0 OverviewASP.NET Core 1.0 Overview
ASP.NET Core 1.0 Overview
 
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
From VMs to Containers: Introducing Docker Containers for Linux and Windows S...
 
Building IoT and Big Data Solutions on Azure
Building IoT and Big Data Solutions on AzureBuilding IoT and Big Data Solutions on Azure
Building IoT and Big Data Solutions on Azure
 
Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015Debugging your Way through .NET with Visual Studio 2015
Debugging your Way through .NET with Visual Studio 2015
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
HTTP/2 Changes Everything
HTTP/2 Changes EverythingHTTP/2 Changes Everything
HTTP/2 Changes Everything
 

Similar to ASP.NET Core 1.0

ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
Eamonn Boyle
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
Alex Thissen
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4Jon Galloway
 
“ASP.NET Core. Features and architecture”
“ASP.NET Core. Features and architecture” “ASP.NET Core. Features and architecture”
“ASP.NET Core. Features and architecture”
HYS Enterprise
 
.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6
aminmesbahi
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»DataArt
 
.NET Core: a new .NET Platform
.NET Core: a new .NET Platform.NET Core: a new .NET Platform
.NET Core: a new .NET Platform
Alex Thissen
 
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
Enea Gabriel
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
rajdeep
 
ASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web AppsASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web Apps
Shahed Chowdhuri
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
Alex Thissen
 
AWS Lambda in C#
AWS Lambda in C#AWS Lambda in C#
AWS Lambda in C#
Amazon Web Services
 
NEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsNEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# Applications
Amazon Web Services
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
Stuart (Pid) Williams
 
Azure App Services
Azure App ServicesAzure App Services
Azure App Services
Alper Ebicoglu
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
SPTechCon
 
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developersChris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.jsAyush Mishra
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
GlobalLogic Ukraine
 

Similar to ASP.NET Core 1.0 (20)

ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
 
MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4SoCal Code Camp 2011 - ASP.NET MVC 4
SoCal Code Camp 2011 - ASP.NET MVC 4
 
“ASP.NET Core. Features and architecture”
“ASP.NET Core. Features and architecture” “ASP.NET Core. Features and architecture”
“ASP.NET Core. Features and architecture”
 
.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6.NET Core, ASP.NET Core Course, Session 6
.NET Core, ASP.NET Core Course, Session 6
 
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
Станислав Сидоренко «DeviceHive Java Server – миграция на Spring Boot»
 
.NET Core: a new .NET Platform
.NET Core: a new .NET Platform.NET Core: a new .NET Platform
.NET Core: a new .NET Platform
 
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
The future of ASP.NET / CodeCamp/Iasi 25 Oct 2014
 
Play Support in Cloud Foundry
Play Support in Cloud FoundryPlay Support in Cloud Foundry
Play Support in Cloud Foundry
 
ASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web AppsASP.NET Core 2.1: The Future of Web Apps
ASP.NET Core 2.1: The Future of Web Apps
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 
AWS Lambda in C#
AWS Lambda in C#AWS Lambda in C#
AWS Lambda in C#
 
NEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# ApplicationsNEW LAUNCH! Developing Serverless C# Applications
NEW LAUNCH! Developing Serverless C# Applications
 
Groovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentationGroovy & Grails eXchange 2012 vert.x presentation
Groovy & Grails eXchange 2012 vert.x presentation
 
Azure App Services
Azure App ServicesAzure App Services
Azure App Services
 
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
Tutorial, Part 2: SharePoint 101: Jump-Starting the Developer by Rob Windsor ...
 
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developersChris O'Brien - Best bits of Azure for Office 365/SharePoint developers
Chris O'Brien - Best bits of Azure for Office 365/SharePoint developers
 
Philly Tech Fest Iis
Philly Tech Fest IisPhilly Tech Fest Iis
Philly Tech Fest Iis
 
An Overview of Node.js
An Overview of Node.jsAn Overview of Node.js
An Overview of Node.js
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
 

More from Ido Flatow

Google Cloud IoT Core
Google Cloud IoT CoreGoogle Cloud IoT Core
Google Cloud IoT Core
Ido Flatow
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
Ido Flatow
 
Production Debugging War Stories
Production Debugging War StoriesProduction Debugging War Stories
Production Debugging War Stories
Ido Flatow
 
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
Migrating Customers to Microsoft Azure: Lessons Learned From the FieldMigrating Customers to Microsoft Azure: Lessons Learned From the Field
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
Ido Flatow
 
Caching in Windows Azure
Caching in Windows AzureCaching in Windows Azure
Caching in Windows Azure
Ido Flatow
 
Automating Windows Azure
Automating Windows AzureAutomating Windows Azure
Automating Windows Azure
Ido Flatow
 

More from Ido Flatow (6)

Google Cloud IoT Core
Google Cloud IoT CoreGoogle Cloud IoT Core
Google Cloud IoT Core
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
Production Debugging War Stories
Production Debugging War StoriesProduction Debugging War Stories
Production Debugging War Stories
 
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
Migrating Customers to Microsoft Azure: Lessons Learned From the FieldMigrating Customers to Microsoft Azure: Lessons Learned From the Field
Migrating Customers to Microsoft Azure: Lessons Learned From the Field
 
Caching in Windows Azure
Caching in Windows AzureCaching in Windows Azure
Caching in Windows Azure
 
Automating Windows Azure
Automating Windows AzureAutomating Windows Azure
Automating Windows Azure
 

Recently uploaded

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

ASP.NET Core 1.0

  • 1. ASP.NET Core: Reimagining Web Application Development in .NET Ido Flatow Senior Architect Microsoft MVP & RD Sela Group @idoflatow
  • 2. Agenda • ASP.NET History • ASP.NET Core 1.0 and .NET • ASP.NET Core 1.0 Features • ASP.NET Core MVC
  • 4. History of ASP (20 years) • 1996 - Active Server Pages (ASP) • 2002 – ASP.NET • 2005 – ASP.NET 2 • 2008 – ASP.NET MVC • 2012 – ASP.NET Web API • 2014 – ASP.NET vNext – 2015 – ASP.NET 5 RC1 – 2016 – ASP.NET Core 1.0 (June 27th, 2016)
  • 5. Problems with ASP.NET Architecture • Limited hosting possibilities (IIS only) • Dependency on IIS environment (System.Web) • Web evolves faster than the .NET Framework • Requires full-blown .NET Framework • Resource intensive and not web-friendly • Hard to optimize for lightweight high-performance apps • Not completely cloud-optimized
  • 6. Introducing ASP.NET Core 1.0 (Tools in Preview 2) OS .NET CLR ASP.NET MVC (UI + API) Host Self-HostedIIS .NET Core CLR Middleware
  • 7. What is Tooling? • Everything that is part of the framework • Command line tools – dotnet CLI • Project tools – ASP.NET templates – xproj / csproj • Visual Studio tools – Configuration IntelliSense – Debugger support
  • 8. Two Runtimes • .NET Full Framework (4.6) – Not going away… – Windows hosting with full .NET APIs • .NET Core 1.0 – Subset of the full framework • No Windows Forms, WPF, Silverlight • No System.Web (WebForms) – Implemented as set of NuGet packages – Cross-platform and Nano server support
  • 9. GETTING TO KNOW ASP.NET CORE
  • 10. ASP.NET Core Features • Flexible and cross-platform runtime • Modular HTTP request pipeline • Unifying MVC, Web API, and Web Pages • Side-by-side versioning with .NET Core • Built-in Dependency Injection • Self-host and IIS-hosted (sort of…) • Open source on GitHub
  • 11. CREATING A NEW ASP.NET CORE PROJECT Demo
  • 12. Solution and Projects • global.json Project references (in addition to the .sln) • wwwroot Root for static content (html, css, js, images, etc…) • Program.cs ASP.NET hosting libraries. This is where it all starts • project.json References, compiler settings, tooling (replaces web.config and packages.config) • Startup.cs DI and pipeline configuration (replaces global.asax and configuration code)
  • 14. ASP.NET Core Middlewares • Improved HTTP performance – New lean and fast HTTP request pipeline – You choose what to use in your application – By registering middlewares public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) { app.UseExceptionHandler("/Home/Error"); app.UseStaticFiles(); app.UseIdentity(); app.UseMvc(routes => ...) }
  • 15. Where’s the AppSettings? • Not relying on web.config anymore • New configuration system based on key/value pairs: – JSON files – INI files – XML files – Environment variables • Configuration can come from multiple resources – Last resource wins
  • 16. Loading Settings var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) .AddXmlFile("appsettings.xml", optional:true) .AddJsonFile($"appsettings.{env.EnvironmentName}.json",true); if (env.IsDevelopment()) { builder.AddUserSecrets(); } builder.AddEnvironmentVariables(); IConfigurationRoot Configuration = builder.Build(); ... string connString = Configuration["Data:Default:ConnectionString"];
  • 17. Dependency Injection • ASP.NET Core is DI-friendly • Basic DI container available throughout the stack • BYOC is also supported (already implemented for Autofac, Dryloc, StructureMap, etc.) • Out-of-the-box container supports: – Singleton / Instance – single instance – Transient – new instance each time – Scoped – new instance per request (HTTP context) • https://github.com/aspnet/DependencyInjection
  • 18. DI with Controllers public class ProductsController : Controller { private readonly IProductsRepository _repository; public ProductsController(IProductsRepository repository) { this._repository = repository; } public IActionResult Index() { var products = _repository.GetAllProducts(); return View(products); } } services.AddTransient<IProductsRepository, DefaultProductsRepository>();
  • 19. Logging • ASP.NET Core has built-in support for logging • Uses the built-in DI to get a logger instance • Standard logger outputs: category, log level, event Id, and message • Built-in loggers for: – Console (hosting from cmd/terminal) – TraceSource (good old System.Diagnostics) – Debug (Visual Studio output window) • Custom loggers are also available (log4net, serilog, elmah, etc.) • https://github.com/aspnet/Logging
  • 20. Logging with Controllers public class TodoController : Controller { private readonly ITodoRepository _todoRepository; private readonly ILogger<TodoController> _logger; private const int LIST_ITEMS = 1001; public TodoController(ITodoRepository todoRepo, ILogger<TodoController> logger) { _todoRepository = todoRepo; _logger = logger; } [HttpGet] public IEnumerable<TodoItem> GetAll() { _logger.LogInformation(LIST_ITEMS, "Listing all items"); EnsureItems(); return _todoRepository.GetAll(); } }
  • 21. The dotnet CLI • Cross-platform command line toolchain • Written in .NET Core • External commands • https://github.com/dotnet/cli dotnet new dotnet restore dotnet build --output /stuff dotnet /stuff/new.dll dotnet publish dotnet ef dotnet razor-tooling Dotnet aspnet-codegenerator
  • 22. Hosting ASP.NET Core • ASP.NET Core 1.0 is a stand-alone application – Uses Kestrel HTTP server (based on libuv, as with node.js) • Self-hosting with .NET Core – Compiled into a .dll file, hosted by the dotnet CLI • Self-hosting with .NET 4.6 – Compiles into an .exe file – Kestrel or the WebListener server (Windows HTTP.sys) • IIS-hosted (.NET Core / .NET 4.6) – IIS uses the ASP.NET Core Module to start the self-hosted app – ASP.NET Core template generates the required web.config – Starts either dotnet webapp1.dll or webapp.exe • https://docs.asp.net/en/latest/hosting/aspnet-core-module.html
  • 25. ASP.NET <= 4.6 Frameworks
  • 27. ASP.NET Core MVC • No more duplication - one set of concepts • Used for creating both UI and API • Based on the new ASP.NET Core pipeline • Supports .NET Core • Built DI first • Runs on IIS or self-host • New features in controllers and views
  • 28. Getting Started with MVC • Project.json • Startup.cs "dependencies": { "Microsoft.AspNet.Server.Kestrel": "1.0.0", // Add this: "Microsoft.AspNet.Mvc": "1.0.0" } // Register MVC default services for DI services.AddMvc(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); });
  • 29. Web API Configuration • Route configuration -> attribute-based routing • Message handlers -> middleware pipeline • Filters and Formatters -> startup.cs services.AddMvc() .AddXmlDataContractSerializerFormatters() .AddMvcOptions(options => { options.Filters.Add(new ValidatorFilterAttribute()); }) .AddJsonOptions(jsonOptions => { jsonOptions.SerializerSettings.Formatting = Formatting.Indented; });
  • 30. Controllers – Two in One • UI – same as with MVC 5 • API – similar, but different public class HomeController : Controller { public IActionResult Index() { return View(); } } [Route("api/[controller]")] public class ProductsController : Controller { [HttpGet("{id:int}")] public Product GetProduct(int id) { return new Product() { ID = id }; } }
  • 31. Actions – IActionResult [HttpGet("{id:int}", Name = "GetByIdRoute")] public IActionResult GetById (int id) { var item = _items.FirstOrDefault(x => x.Id == id); if (item == null) { return NotFound(); } return new ObjectResult(item); } [HttpPost] public IActionResult CreateTodoItem([FromBody] TodoItem item) { _items.Add(item); return CreatedAtRoute( "GetByIdRoute", new { id = item.Id }, item); }
  • 32. Showing Some UI for Your API • Swagger - a JSON-based service description framework • Create a Swagger endpoint using Swashbuckle.SwaggerGen – Browse to /swagger/v1/swagger.json • Host a built-in UI for testing APIs with Swashbuckle.SwaggerUi – Browse to /swagger/ui "dependencies": { "Swashbuckle.SwaggerGen": "6.0.0-beta901", "Swashbuckle.SwaggerUi": "6.0.0-beta901" } services.AddSwaggerGen(); app.UseSwagger(); app.UseSwaggerUi();
  • 33. Enough with controllers, What about views? Oh, right!
  • 34. Injecting Services to Views • Preferable than using static classes/methods • Use interfaces instead of concrete types • Register in IoC using different lifecycles public class CatalogService : ICatalogService { public async Task<int> GetTotalProducts() {...} // From ICatalogService } @inject MyApp.Services.ICatalogService Catalog <html> <body> <h3>Number of products in the catalog</h3> @await Catalog.GetTotalProducts() </body> </html> services.AddTransient<ICatalogService, CatalogService>();
  • 35. Flushing Content with Razor • In ASP.NET <= 5, browser had to wait until Razor rendered the entire page • Razor now supports flushing, causing HTML to get chunked (streamed) – @await FlushAsync() • Not supported when rendering layout sections
  • 36. Last, but not Least, Tag Helpers • Tag helpers are an alternative to HTML helpers • Tag helpers look like regular HTML elements • Instead of doing this: • Do this: • It’s the return of Web Controls, NOOOOOO!!! @Html.ActionLink("Click me", "AnotherAction") <a asp-action="AnotherAction">Click me</a>
  • 37. Tag Helpers are not Evil • Tag Helpers generate markup within their enclosing tag • Less Razor/HTML mess in the .cshtml file • Data-attributes style approach • Use C# to better construct the markup – Add/remove parts from the inner content – Generate complex HTML (recursive, nested, …) – Cache the output
  • 38. Existing Tag Helpers • HTML elements – <a>, <form>, <input>, <label>, <link>, <script>, <select>, <textarea> • Logical – <cache> • Placeholders – ValidationSummary (<div>), ValidationMessage (<span>) • You can create your own Tag Helpers • Check out the source for reference https://github.com/aspnet/Mvc/tree/dev/src/Microsoft.AspNetCore.Mvc.TagHelpers
  • 39. Key Improvements in ASP.NET Core • Totally modular - Everything is a package • Lightweight - you use minimum set of modules • Faster startup, lower memory footprint • Can be deployed side-by-side with .NET Core • Cross platform - can be hosted anywhere • Better developer experience – DI and one MVC • Everything is open-sourced
  • 40. Key Improvements in ASP.NET Core
  • 41. Get Started with ASP.NET Core • Install Visual Studio 2015 / Visual Studio Code • Walkthroughs and samples at http://www.asp.net/core • Documentation at http://docs.asp.net/en/latest • Get the code from http://github.com/aspnet • Read blogs at http://blogs.msdn.com/b/webdev • @IdoFlatow // idof@sela.co.il // http://www.idoflatow.net/downloads

Editor's Notes

  1. http://docs.asp.net/en/latest/security/app-secrets.html
  2. ($"appsettings.{env.EnvironmentName}.json” The $ is C# 6 string interpolation
  3. Other dependencies that people may find relevant: aspnet.diagnostics, server.weblistener
  4. For XML, add a nuget to the project.json: "Microsoft.AspNet.Mvc.Formatters.Xml": "6.0.0-rc1-final",
  5. Other dependencies that people may find relevant: aspnet.diagnostics, server.weblistener
  6. Don’t use void with beta3, it ignores status codes set in the method
  7. Null returns 204, but void return 200 empty https://github.com/aspnet/Mvc/issues/4096
  8. Other dependencies that people may find relevant: aspnet.diagnostics, server.weblistener