![Page 1: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/1.jpg)
Building Modern Web Applications with ASP.NET 5
Brij Bhushan Mishra
![Page 2: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/2.jpg)
Agenda
• Introduction
• Middleware
• Dependency Injection
• Configuration
• View Component
• QnA
![Page 3: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/3.jpg)
About Me
Brij Bhushan Mishra- Microsoft MVP - ASP.NET/IIS (4 Times)
- Architect/Consultant
- Blogger/Author
- http://codewala.net
- @code_wala
![Page 4: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/4.jpg)
ASP.NET 5 – the key drivers
• Agility
• Productivity
• Performance
• Cloud
• Hybrid
![Page 5: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/5.jpg)
ASP.NET 5
![Page 6: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/6.jpg)
Hello ASP.NET 5
Demo
![Page 7: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/7.jpg)
Where is my HTTP Pipeline?
![Page 8: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/8.jpg)
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
![Page 9: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/9.jpg)
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
![Page 10: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/10.jpg)
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
![Page 11: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/11.jpg)
Middleware
Processes the HTTPContext items
HTTPContext
_next
_next(httpcontext)_next(httpcontext)
![Page 12: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/12.jpg)
Middleware Chaining
Middleware1 Middleware2 Middleware3 Middleware4
Request
Response
![Page 13: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/13.jpg)
Let’s add some middlewares
Demo
![Page 14: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/14.jpg)
Dependency Injection
![Page 15: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/15.jpg)
Dependency Injection
Dependency Inversion Principle
Inversion of Control (IOC)
Service Locator (SL)Dependency Injection
![Page 16: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/16.jpg)
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
![Page 17: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/17.jpg)
Time to inject dependencies
Demo
![Page 18: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/18.jpg)
Where are Config files
![Page 19: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/19.jpg)
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
![Page 20: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/20.jpg)
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
![Page 21: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/21.jpg)
Add entry in Config
Demo
![Page 22: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/22.jpg)
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
![Page 23: Building Modern Web Applications with ASP.NET 5developermarch.com/developersummit/2015/report/download... · 2015-04-29 · Building Modern Web Applications with ASP.NET 5 Brij Bhushan](https://reader034.vdocument.in/reader034/viewer/2022042411/5f2950a88b22433af060f7e3/html5/thumbnails/23.jpg)