SlideShare a Scribd company logo
MVC 6 - the new unified Web programming model
Alex Thissen
Lead Consultant Xpirit
ASP.NET MVC 6
A new unified programming model for the web
Agenda
• Short overview ASP.NET 5
• A unified programming model
• Controllers
• Dependency Injection
• Routing
• Summary
• Questions and Answers
An overview
Viewing from 10.000 feet
ASP.NET components
MVC 6
Unified Web Stack
Characteristics of MVC 6
•One set of concepts – remove duplication
•Web UI and APIs combined
•Smooth transition from Web Pages to MVC
Unified
•Run on IIS or self-host or cross-platform
•Based on new request pipeline in ASP.NET 5
•Runs in cloud-optimized Core CLR
Built on top
of ASP.NET 5
•Pay as you use
•Middleware
•Built with Dependency Injection first
Modular
Getting familiar
.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
Standing on the shoulders of a new giant
ASP.NET 5.0 ASP.NET 5.0 ASP.NET 5.0
Getting started
• Middleware model introduced by OWIN
Ready, set, start – a lap around MVC 6
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);
public void Configure(IApplicationBuilder app)
{
app.Map("/Nancy",
builder =>
{ builder.UseRuntimeInfo();
builder.RunNancyFx();
});
app.UseCors();
app.UseMvc(cfg);
Use, Map and Run
app.UseErrorPage();
Application FX
Middleware
Controllers
• Single base class for
MVC and Web API
• Not required
• POCO Controllers
• No base class
• Combine Web API and
MVC in 1 class
• UI and REST endpoints
at one base URI
Not your typical gaming gear
Dependency Injection
It all depends
Dependency Injection
• DI is core part of runtime
• Built-in DI for configuration and services
– Default lightweight 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>();
Built-in DI Container
• Register mappings in ConfigureServices of Startup
• Default registrations
• Lifetimes
– Transient
– Scoped
– Singleton
– Instance
• Rules for registering mapping
– First one wins
– Allows you to get ahead off default mappings
Sometimes better is worse than good enough
Activation
Activation method Example
Constructor on classes MyController(ILog logger)
Attribute on field or
property
[Activate]
ILog Logger { get;set; }
Attribute in action [FromServices] ILog logger
Directive in Razor page ILog logger
Inject those objects
@inject
Tag Helpers
• Allow server-side code to participate in rendering of
HTML elements in Razor files
• Target HTML elements based on element and attribute
names
• Reduce explicit transitions between HTML and C#
• Take advantage of composition and tooling benefits in
Visual Studio Code and 2015
Getting some help in Razor
Custom Tag Helpers
namespace TechDays.TagHelpers
{
[TargetElement("datumtijd")]
public class DateTimeTagHelper : TagHelper
{
public override void Process(TagHelperContext context,
TagHelperOutput output) {
output.Content.SetContent(DateTime.Now.ToString());
}
}
}
// Inside Razor .cshtml file
@addTagHelper "*, TechDays.TagHelpers"
Routing
• Familiar MVC 5 attribute based routing
• Enabled by default
• Special tokens: [controller] and [action]
Show me the way
[Route("api/Hello")]
public class HelloController : Controller
{
[Route]
public string Get()
{
return "hello";
}
}
[Route("api/[controller]")]
public class HelloController : Controller
{
[Route]
public string Get()
{
return "hello";
}
}
View components
• Comparable to Web Forms’ UserControls
• Different from Partial Views
• Combines code and view as logical unit
User controls in MVC style
Logging
• Pluggable logging infrastructure provided
• ILoggerFactory
• Logging levels
– from Debug up to Criticial
Summary
• Unified programming model
• Built on ASP.NET 5
• Learn Dependency Injection
• Command-line vs. Visual Studio
Key takeaways from ASP.NET MVC 6
Your feedback is important!
Scan the QR Code and let us know via the TechDays App.
Laat ons weten wat u van de sessie vindt!
Scan the QR Code via de TechDays App.
Bent u al lid van de Microsot Virtual Academy?! Op MVA kunt u altijd iets
nieuws leren over de laatste technologie van Microsoft. Meld u vandaag aan
op de MVA Stand. MVA biedt 7/24 gratis online training on-demand voor IT-
Professionals en Ontwikkelaars.
MVC 6 - the new unified Web programming model

More Related Content

PPTX
ASP.NET vNext
PPTX
Run your Dockerized ASP.NET application on Windows and Linux!
PPTX
Micro Services in .NET Core and Docker
PPTX
Container Patterns
PPTX
Microservices in Azure
PPTX
Exploring Microservices in a Microsoft Landscape
PDF
Securing Containers From Day One | null Ahmedabad Meetup
PDF
Microservices with Spring Cloud
ASP.NET vNext
Run your Dockerized ASP.NET application on Windows and Linux!
Micro Services in .NET Core and Docker
Container Patterns
Microservices in Azure
Exploring Microservices in a Microsoft Landscape
Securing Containers From Day One | null Ahmedabad Meetup
Microservices with Spring Cloud

What's hot (20)

PPTX
Tokyo azure meetup #12 service fabric internals
PPTX
Grails in the Cloud (2013)
PPTX
IPaaS 2.0: Fuse Integration Services (Robert Davies & Keith Babo)
PPTX
Data stores: beyond relational databases
PDF
Node and Micro-Services at IBM
PDF
Who needs containers in a serverless world
PDF
How Apache Kafka® Works
PPTX
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
PDF
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
PDF
WSO2Con USA 2017: Scalable Real-time Complex Event Processing at Uber
PDF
Gradual migration to MicroProfile
PPTX
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
PPTX
Cloudsolutionday 2016: Docker & FAAS at getvero.com
PPTX
.NET microservices with Azure Service Fabric
PPTX
JavaEE Microservices platforms
PPTX
Kubernetes as Orchestrator for A10 Lightning Controller
PPTX
Automation 2.0 - Automation Tools for Hybrid Cloud Environments
PDF
Secure JAX-RS
PPTX
Techniques for scaling application with security and visibility in cloud
PPTX
104 meets cloud
Tokyo azure meetup #12 service fabric internals
Grails in the Cloud (2013)
IPaaS 2.0: Fuse Integration Services (Robert Davies & Keith Babo)
Data stores: beyond relational databases
Node and Micro-Services at IBM
Who needs containers in a serverless world
How Apache Kafka® Works
Full Stack Development With Node.Js And NoSQL (Nic Raboy & Arun Gupta)
How Class Data Sharing Can Speed up Your Jakarta EE Application Startup
WSO2Con USA 2017: Scalable Real-time Complex Event Processing at Uber
Gradual migration to MicroProfile
Azure Service Fabric and the Actor Model: when did we forget Object Orientation?
Cloudsolutionday 2016: Docker & FAAS at getvero.com
.NET microservices with Azure Service Fabric
JavaEE Microservices platforms
Kubernetes as Orchestrator for A10 Lightning Controller
Automation 2.0 - Automation Tools for Hybrid Cloud Environments
Secure JAX-RS
Techniques for scaling application with security and visibility in cloud
104 meets cloud
Ad

Viewers also liked (13)

PDF
MZ_Educational_Dev
PPTX
Caracteristicas y mediaciones de la educacion a distancia
PPTX
Comment intégrer les switch Nebula à votre réseau
PDF
Highlight Portfolio_Xinyi Huang(April2016) (dragged)
PPTX
Redes sociales
PDF
Padilla sosa lizeth_margarita_tarea3
PPTX
хакимкаиргельды+компания+клиенты
PDF
Near_Neighbours_Coventry_University_Evaluation (1)
PPT
серкеноваулжан+ремонтквартир+клиенты
PDF
Marketing
MZ_Educational_Dev
Caracteristicas y mediaciones de la educacion a distancia
Comment intégrer les switch Nebula à votre réseau
Highlight Portfolio_Xinyi Huang(April2016) (dragged)
Redes sociales
Padilla sosa lizeth_margarita_tarea3
хакимкаиргельды+компания+клиенты
Near_Neighbours_Coventry_University_Evaluation (1)
серкеноваулжан+ремонтквартир+клиенты
Marketing
Ad

Similar to MVC 6 - the new unified Web programming model (20)

PPTX
.NET Core: a new .NET Platform
PPTX
ASP.NET - Building Web Application..in the right way!
PPTX
ASP.NET - Building Web Application..in the right way!
PPTX
ASP.NET Core 1.0
PPTX
Webinar MVC6
PPTX
PDF
Learning Aspnet Core Mvc Programming Mugilan T S Ragupathi
PDF
ASP.NET Core in Action (2018).pdf
PPTX
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
PPTX
Web API or WCF - An Architectural Comparison
PDF
ASP.NET MVC - Whats The Big Deal
PDF
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
PPTX
2011 NetUG HH: ASP.NET MVC & HTML 5
DOCX
A report on mvc using the information
PDF
【BS1】What’s new in visual studio 2022 and c# 10
PPTX
Learning ASP.NET 5 and MVC 6
PDF
Mastering asp.net mvc - Dot Net Tricks
PPTX
ASP.Net 5 and C# 6
.NET Core: a new .NET Platform
ASP.NET - Building Web Application..in the right way!
ASP.NET - Building Web Application..in the right way!
ASP.NET Core 1.0
Webinar MVC6
Learning Aspnet Core Mvc Programming Mugilan T S Ragupathi
ASP.NET Core in Action (2018).pdf
ZZ BC#8 Hello ASP.NET MVC 4 (dks)
Web API or WCF - An Architectural Comparison
ASP.NET MVC - Whats The Big Deal
ChircuVictor StefircaMadalin rad_aspmvc3_wcf_vs2010
2011 NetUG HH: ASP.NET MVC & HTML 5
A report on mvc using the information
【BS1】What’s new in visual studio 2022 and c# 10
Learning ASP.NET 5 and MVC 6
Mastering asp.net mvc - Dot Net Tricks
ASP.Net 5 and C# 6

More from Alex Thissen (15)

PPTX
Go (con)figure - Making sense of .NET configuration
PPTX
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
PPTX
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
PPTX
Health monitoring and dependency injection - CNUG November 2019
PPTX
Architecting .NET solutions in a Docker ecosystem - .NET Fest Kyiv 2019
PPTX
I dont feel so well. Integrating health checks in your .NET Core solutions - ...
PPTX
It depends: Loving .NET Core dependency injection or not
PPTX
Overview of the new .NET Core and .NET Platform Standard
PPTX
How Docker and ASP.NET Core will change the life of a Microsoft developer
PPTX
Visual Studio Productivity tips
PPTX
Exploring microservices in a Microsoft landscape
PPTX
Asynchronous programming in ASP.NET
PPTX
Visual Studio 2015 experts tips and tricks
PPTX
ASP.NET 5 - Microsoft's Web development platform reimagined
PPTX
//customer/
Go (con)figure - Making sense of .NET configuration
Logging, tracing and metrics: Instrumentation in .NET 5 and Azure
Logging tracing and metrics in .NET Core and Azure - dotnetdays 2020
Health monitoring and dependency injection - CNUG November 2019
Architecting .NET solutions in a Docker ecosystem - .NET Fest Kyiv 2019
I dont feel so well. Integrating health checks in your .NET Core solutions - ...
It depends: Loving .NET Core dependency injection or not
Overview of the new .NET Core and .NET Platform Standard
How Docker and ASP.NET Core will change the life of a Microsoft developer
Visual Studio Productivity tips
Exploring microservices in a Microsoft landscape
Asynchronous programming in ASP.NET
Visual Studio 2015 experts tips and tricks
ASP.NET 5 - Microsoft's Web development platform reimagined
//customer/

Recently uploaded (20)

PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Essential Infomation Tech presentation.pptx
PDF
System and Network Administration Chapter 2
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
top salesforce developer skills in 2025.pdf
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
history of c programming in notes for students .pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
AI in Product Development-omnex systems
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
How Creative Agencies Leverage Project Management Software.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Odoo Companies in India – Driving Business Transformation.pdf
Essential Infomation Tech presentation.pptx
System and Network Administration Chapter 2
Odoo POS Development Services by CandidRoot Solutions
top salesforce developer skills in 2025.pdf
CHAPTER 2 - PM Management and IT Context
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Operating system designcfffgfgggggggvggggggggg
Understanding Forklifts - TECH EHS Solution
Design an Analysis of Algorithms I-SECS-1021-03
wealthsignaloriginal-com-DS-text-... (1).pdf
Softaken Excel to vCard Converter Software.pdf
history of c programming in notes for students .pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
AI in Product Development-omnex systems
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...

MVC 6 - the new unified Web programming model

  • 2. Alex Thissen Lead Consultant Xpirit ASP.NET MVC 6 A new unified programming model for the web
  • 3. Agenda • Short overview ASP.NET 5 • A unified programming model • Controllers • Dependency Injection • Routing • Summary • Questions and Answers
  • 6. Characteristics of MVC 6 •One set of concepts – remove duplication •Web UI and APIs combined •Smooth transition from Web Pages to MVC Unified •Run on IIS or self-host or cross-platform •Based on new request pipeline in ASP.NET 5 •Runs in cloud-optimized Core CLR Built on top of ASP.NET 5 •Pay as you use •Middleware •Built with Dependency Injection first Modular Getting familiar
  • 7. .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 Standing on the shoulders of a new giant ASP.NET 5.0 ASP.NET 5.0 ASP.NET 5.0
  • 8. Getting started • Middleware model introduced by OWIN Ready, set, start – a lap around MVC 6
  • 9. 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);
  • 10. public void Configure(IApplicationBuilder app) { app.Map("/Nancy", builder => { builder.UseRuntimeInfo(); builder.RunNancyFx(); }); app.UseCors(); app.UseMvc(cfg); Use, Map and Run app.UseErrorPage(); Application FX Middleware
  • 11. Controllers • Single base class for MVC and Web API • Not required • POCO Controllers • No base class • Combine Web API and MVC in 1 class • UI and REST endpoints at one base URI Not your typical gaming gear
  • 13. Dependency Injection • DI is core part of runtime • Built-in DI for configuration and services – Default lightweight 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>();
  • 14. Built-in DI Container • Register mappings in ConfigureServices of Startup • Default registrations • Lifetimes – Transient – Scoped – Singleton – Instance • Rules for registering mapping – First one wins – Allows you to get ahead off default mappings Sometimes better is worse than good enough
  • 15. Activation Activation method Example Constructor on classes MyController(ILog logger) Attribute on field or property [Activate] ILog Logger { get;set; } Attribute in action [FromServices] ILog logger Directive in Razor page ILog logger Inject those objects @inject
  • 16. Tag Helpers • Allow server-side code to participate in rendering of HTML elements in Razor files • Target HTML elements based on element and attribute names • Reduce explicit transitions between HTML and C# • Take advantage of composition and tooling benefits in Visual Studio Code and 2015 Getting some help in Razor
  • 17. Custom Tag Helpers namespace TechDays.TagHelpers { [TargetElement("datumtijd")] public class DateTimeTagHelper : TagHelper { public override void Process(TagHelperContext context, TagHelperOutput output) { output.Content.SetContent(DateTime.Now.ToString()); } } } // Inside Razor .cshtml file @addTagHelper "*, TechDays.TagHelpers"
  • 18. Routing • Familiar MVC 5 attribute based routing • Enabled by default • Special tokens: [controller] and [action] Show me the way [Route("api/Hello")] public class HelloController : Controller { [Route] public string Get() { return "hello"; } } [Route("api/[controller]")] public class HelloController : Controller { [Route] public string Get() { return "hello"; } }
  • 19. View components • Comparable to Web Forms’ UserControls • Different from Partial Views • Combines code and view as logical unit User controls in MVC style
  • 20. Logging • Pluggable logging infrastructure provided • ILoggerFactory • Logging levels – from Debug up to Criticial
  • 21. Summary • Unified programming model • Built on ASP.NET 5 • Learn Dependency Injection • Command-line vs. Visual Studio Key takeaways from ASP.NET MVC 6
  • 22. Your feedback is important! Scan the QR Code and let us know via the TechDays App. Laat ons weten wat u van de sessie vindt! Scan the QR Code via de TechDays App. Bent u al lid van de Microsot Virtual Academy?! Op MVA kunt u altijd iets nieuws leren over de laatste technologie van Microsoft. Meld u vandaag aan op de MVA Stand. MVA biedt 7/24 gratis online training on-demand voor IT- Professionals en Ontwikkelaars.

Editor's Notes

  • #16: diego_cervo/istockphoto.com