Building Modern Web Applications with ASP.NET 5
Brij Bhushan Mishra
Agenda
• Introduction
• Middleware
• Dependency Injection
• Configuration
• View Component
• QnA
About Me
Brij Bhushan Mishra- Microsoft MVP - ASP.NET/IIS (4 Times)
- Architect/Consultant
- Blogger/Author
- http://codewala.net
- @code_wala
ASP.NET 5 – the key drivers
• Agility
• Productivity
• Performance
• Cloud
• Hybrid
ASP.NET 5
Hello ASP.NET 5
Demo
Where is my HTTP Pipeline?
HTTP Pipeline
HTTPModule 1
HTTPModule 2
HTTPModule 3
HTTPModule n
HTTP Handler
Request Response
.
.
.
1• Application_BeginRequest
2• Application_AuthenticateRequest
3• Application_AuthorizeRequest
7• Application_PreRequestHandlerExecute
8•Handler executes the request
9•Application_PostRequestHandlerExecute
10• Application_ReleaseRequestCache
11• Application_UpdateRequestCache
12• Application_EndRequest
1• Application_BeginRequest
2• Application_AuthenticateRequest
3• Application_AuthorizeRequest
OWIN
OWIN defines a standard interface between .NET
web servers and web applications. The goal of the
OWIN interface is to decouple server and
application, encourage the development of simple
modules for .NET web development, and, by being
an open standard, stimulate the open source
ecosystem of .NET web development tools
Middleware
Pass through components that form a pipeline between a server and application to inspect, route, or modify request and response messages for a specific purpose.
It’s same as a HTTP Module
Middleware
Processes the HTTPContext items
HTTPContext
_next
_next(httpcontext)_next(httpcontext)
Middleware Chaining
Middleware1 Middleware2 Middleware3 Middleware4
Request
Response
Let’s add some middlewares
Demo
Dependency Injection
Dependency Injection
Dependency Inversion Principle
Inversion of Control (IOC)
Service Locator (SL)Dependency Injection
How?
• Startup class has one more method to inject the dependencies.
• These can be injected via property or constructor in any component.
• ConfigureServices
– Instance
– Transient
– Scoped
– Singleton
Time to inject dependencies
Demo
Where are Config files
Where are configuration files
Earlier
• *.config files at different levels
• System.Configuration namespace to play with configfiles
Now
• These are not supported
• Lightweight that works on Cloud
• Different configuration in different environment
What we get
• Light-weight
• Should work same everywhere, cloud optimized
• Have different configuration instance for different sub system like Identity, MVC, Razor
• Able to load configuration from diff sources
• Instantiated and Initialized in application itself
• Supports
– Json, xml,ini, environment variables, command line
Add entry in Config
Demo
View Component
• A simple replacement for child actions
• Can be used instead Partial Views as well
• Easy separation of concerns and testable
• Provide the power of async
• Contains two parts
– A class that inherits from ViewComponent
– A razor view which call VC method
Top Related