SlideShare a Scribd company logo
ASP.NET MVC 4 Request Pipeline
Lukasz Lysik
ASP.NET MVC 4 Study Group
20/08/2013
ASP.NET MVC Request Pipeline
http://localhost/Controller/Action/1
Hello
World!
HTTP Modules and HTTP Handlers
(Not directly related to ASP.NET MVC but short
introduction will help understand further topics.)
An HTTP module is an assembly that is called on every
request made to your application.
An HTTP handler is the process (frequently referred to
as the "endpoint") that runs in response to a request
made to an ASP.NET Web application.
Source: http://msdn.microsoft.com/en-us/library/bb398986%28v=vs.100%29.aspx
HTTP Modules and HTTP Handlers
HTTP
Module 1
HTTP
Module 2
HTTP
Module 3
HTTP
Module 4
HTTP Handler
“HttpHandler is where the request train is headed. HttpModule is a station along the way.”
Source: http://stackoverflow.com/questions/6449132/http-handler-vs-http-module
Typical Uses
HTTP Modules
Security
Statistics and logging
Custom headers or
footers
HTTP Handlers
RSS feeds
Image server
Custom HTTP Modules
public class HelloWorldModule : IHttpModule
{
public void Init(HttpApplication application)
{
application.BeginRequest += (new EventHandler(this.Application_BeginRequest));
application.EndRequest += (new EventHandler(this.Application_EndRequest));
}
private void Application_BeginRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<h1><font color=red> HelloWorldModule: Beginning of Request </font></h1><hr>");
}
private void Application_EndRequest(Object source, EventArgs e)
{
HttpApplication application = (HttpApplication)source;
HttpContext context = application.Context;
context.Response.Write("<hr><h1><font color=red> HelloWorldModule: End of Request</font></h1>");
}
public void Dispose() { }
}
<configuration>
<system.web>
<httpModules>
<add name="HelloWorldModule" type="HelloWorldModule"/>
</httpModules>
</system.web>
</configuration>
Source: http://msdn.microsoft.com/en-us/library/ms227673%28v=vs.85%29.aspx
public interface IHttpModule
{
void Init(HttpApplication context);
void Dispose();
}
Custom HTTP Handlers
using System.Web;
public class HelloWorldHandler : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
HttpRequest Request = context.Request;
HttpResponse Response = context.Response;
Response.Write("<html>");
Response.Write("<body>");
Response.Write("<h1>Hello from a synchronous custom HTTP handler.</h1>");
Response.Write("</body>");
Response.Write("</html>");
}
public bool IsReusable
{
get { return false; }
}
}
public interface IHttpHandler
{
bool IsReusable { get; }
void ProcessRequest(HttpContext context);
}
<configuration>
<system.web>
<httpHandlers>
<add verb="*" path="*.sample" type="HelloWorldHandler"/>
</httpHandlers>
</system.web>
</configuration>
Source: http://msdn.microsoft.com/en-us/library/ms228090%28v=vs.100%29.aspx
If you plan to write your own web framework this is good starting point.
Existing HTTP Modules and HTTP
Handlers
HTTP Modules and HTTP Handlers are registered in
.NET Framework’s Web.config:
c:WindowsMicrosoft.NETFrameworkv4.0.30319Configweb.config
Further info: http://programmer.lysik.pl/2013/08/asp-net-http-modules-and-http-handlers.html
ASP.NET MVC Request Pipeline
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
It all start with UrlRoutingModule.
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
HTTP Handler
HTTP
Module 1
HTTP
Module 2
UrlRoutingModule
RouteTable.Routes
MvcHandler
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
MvcApplication (Global.asax)
RouteTable.Routes
(System.Web.Routing)
System.Web.Mvc.RouteCollectionExtensions
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
Url IRouteHandler Defaults Constraints DataTokens
/Category/{action}/{id} PageRouteHandler … … …
/{controller}/{action}/{id} MvcRouteHandler … … …
… … … … …
RouteTable.Routes
(System.Web.Routing)RouteTable.Routes in fact contains:
Classes that implement IRouteHandler are not HTTP handlers! But they should return one.
System.Web.Mvc.MvcRouteHandler MvcHandler
System.Web.Routing.PageRouteHandler Page or UrlAuthFailureHandler
System.Web.WebPages.ApplicationParts.ResourceRouteHandler ResourceHandler
System.ServiceModel.Activation.ServiceRouteHandler AspNetRouteServiceHttpHandler
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
HTTP Handler
HTTP
Module 1
HTTP
Module 2
UrlRoutingModule
RouteTable.Routes
MvcHandler
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
UrlRoutingModule
1
2
3
4
RemapHandler tells IIS which HTTP handler we want to use.
RouteTable.Routes
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
1
RouteTable.Routes
(System.Web.Routing)
RouteCollection
public RouteData GetRouteData(HttpContextBase httpContext)
{
if (this.Count == 0) return (RouteData) null;
. . .
foreach (RouteBase routeBase in (Collection<RouteBase>) this)
{
RouteData routeData = routeBase.GetRouteData(httpContext);
if (routeData != null)
{
return routeData;
}
}
return (RouteData) null;
}
public override RouteData GetRouteData(HttpContextBase httpContext)
{
RouteValueDictionary values = this._parsedRoute.Match(httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(2)
+ httpContext.Request.PathInfo, this.Defaults);
RouteData routeData = new RouteData((RouteBase) this, this.RouteHandler);
if (!this.ProcessConstraints(httpContext, values, RouteDirection.IncomingRequest))
return (RouteData) null;
. . .
return routeData;
}
Route
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
HTTP Handler
HTTP
Module 1
HTTP
Module 2
UrlRoutingModule
RouteTable.Routes
MvcHandler
4
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
MvcHandler
Controller Builder
3. Call Execute on created Controller
2. Create Controller using ControllerFactory
1. Get ControllerFactory
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
MvcHandler
private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory)
{
. . .
string requiredString = this.RequestContext.RouteData.GetRequiredString("controller");
factory = this.ControllerBuilder.GetControllerFactory();
controller = factory.CreateController(this.RequestContext, requiredString);
if (controller != null)
return;
. . .
}
2
1
3
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
factory = this.ControllerBuilder.GetControllerFactory();
controller = factory.CreateController(this.RequestContext, requiredString);
2
ControllerBuilder
internal ControllerBuilder(IResolver<IControllerFactory> serviceResolver)
{
ControllerBuilder controllerBuilder = this;
IResolver<IControllerFactory> resolver = serviceResolver;
if (resolver == null)
resolver = (IResolver<IControllerFactory>) new SingleServiceResolver<IControllerFactory>(
(Func<IControllerFactory>) (() => this._factoryThunk()), (IControllerFactory) new DefaultControllerFactory()
{
ControllerBuilder = this
}, "ControllerBuilder.GetControllerFactory");
controllerBuilder._serviceResolver = resolver;
}
public class CustomControllerFactory : IControllerFactory
{
public IController CreateController(RequestContext requestContext, string controllerName)
{
. . .
}
}
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
IControllerFactory factory = new CustomControllerFactory();
ControllerBuilder.Current.SetControllerFactory(factory);
}
}
Custom Controller Factory
MvcHandler
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
Controller / ControllerBase
Dependency
Resolution
4. Call InvokeAction on action invoker.
3. Get action invoker.
2. Get action name from RouteData.
1. Call ExecuteCore
0. Execute being called by MvcHandler
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
3
ControllerBase
Controller : ControllerBase
protected override void ExecuteCore()
{
. . .
string requiredString = this.RouteData.GetRequiredString("action");
this.ActionInvoker.InvokeAction(this.ControllerContext, requiredString);
. . .
}
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
3
Controller : ControllerBase
protected virtual IActionInvoker CreateActionInvoker()
{
return (IActionInvoker) DependencyResolverExtensions.GetService<IAsyncActionInvoker>(this.Resolver)
?? DependencyResolverExtensions.GetService<IActionInvoker>(this.Resolver)
?? (IActionInvoker) new AsyncControllerActionInvoker();
}
Possible methods of replacing default
ActionInvoker:
• Assign to ActionInvoker property.
• Override CreateActionInvoker method.
• Use dependency injection.
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
6. Invoke action result
5. Invoke action
4. Bind models.
3. Invoke authorization filters.
2. Find action using descriptor
1. Get controller descriptor (reflection).
0. InvokeAction being called by Controller.ExecuteCore
ActionInvoker
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
ControllerActionInvoker : IActionInvoker
this.ActionInvoker.InvokeAction(this.ControllerContext, requiredString);
1
2
3
4
6
5
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
4
ControllerActionInvoker : IActionInvoker
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
6
ControllerActionInvoker : IActionInvoker
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
ViewResultBase
ViewResultBase
ViewResult PartialViewResult
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
ViewResult
PartialViewResult
1. Routing
2. Controller
execution
3. Action
execution
4. Result
execution
JsonResult
HttpStatusCodeResult
Questions?

More Related Content

What's hot

Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggy
Andrey Karpov
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascript
Eldar Djafarov
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
Steve Loughran
 
Ten mistakes functional java
Ten mistakes functional javaTen mistakes functional java
Ten mistakes functional java
Brian Vermeer
 
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterHow To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
VCP Muthukrishna
 
Automate that
Automate thatAutomate that
Automate that
Atlassian
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
Richard Leland
 
Appium Automation with Kotlin
Appium Automation with KotlinAppium Automation with Kotlin
Appium Automation with Kotlin
RapidValue
 
Unit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterUnit testing CourseSites Apache Filter
Unit testing CourseSites Apache Filter
Wayan Wira
 
Introduction to Celery
Introduction to CeleryIntroduction to Celery
Introduction to Celery
Chathuranga Bandara
 
Servlet
ServletServlet
Servlet
Rami Nayan
 
Retrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberRetrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saber
Bruno Vieira
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum
 
How To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsHow To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional Statements
VCP Muthukrishna
 
BEAMing With Joy
BEAMing With JoyBEAMing With Joy
BEAMing With Joy
⌨️ Steven Proctor
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
HyukSun Kwon
 
How To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueHow To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter Value
VCP Muthukrishna
 
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult CasesPositive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days
 
How to instantiate any view controller for free
How to instantiate any view controller for freeHow to instantiate any view controller for free
How to instantiate any view controller for free
BenotCaron
 

What's hot (20)

Why Windows 8 drivers are buggy
Why Windows 8 drivers are buggyWhy Windows 8 drivers are buggy
Why Windows 8 drivers are buggy
 
node.js practical guide to serverside javascript
node.js practical guide to serverside javascriptnode.js practical guide to serverside javascript
node.js practical guide to serverside javascript
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Ten mistakes functional java
Ten mistakes functional javaTen mistakes functional java
Ten mistakes functional java
 
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional ParameterHow To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
 
Automate that
Automate thatAutomate that
Automate that
 
Celery: The Distributed Task Queue
Celery: The Distributed Task QueueCelery: The Distributed Task Queue
Celery: The Distributed Task Queue
 
Appium Automation with Kotlin
Appium Automation with KotlinAppium Automation with Kotlin
Appium Automation with Kotlin
 
Unit testing CourseSites Apache Filter
Unit testing CourseSites Apache FilterUnit testing CourseSites Apache Filter
Unit testing CourseSites Apache Filter
 
Introduction to Celery
Introduction to CeleryIntroduction to Celery
Introduction to Celery
 
Servlet
ServletServlet
Servlet
 
Retrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saberRetrofit 2 - O que devemos saber
Retrofit 2 - O que devemos saber
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
 
How To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional StatementsHow To Construct IF and Else Conditional Statements
How To Construct IF and Else Conditional Statements
 
BEAMing With Joy
BEAMing With JoyBEAMing With Joy
BEAMing With Joy
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design PatternAsp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
 
Springboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with testSpringboot2 postgresql-jpa-hibernate-crud-example with test
Springboot2 postgresql-jpa-hibernate-crud-example with test
 
How To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter ValueHow To Create Power Shell Function Mandatory Parameter Value
How To Create Power Shell Function Mandatory Parameter Value
 
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult CasesPositive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
 
How to instantiate any view controller for free
How to instantiate any view controller for freeHow to instantiate any view controller for free
How to instantiate any view controller for free
 

Viewers also liked

Hyves Cbw Mitex Harry Van Wouter
Hyves Cbw Mitex Harry Van WouterHyves Cbw Mitex Harry Van Wouter
Hyves Cbw Mitex Harry Van Wouterguest2f17d3
 
Muhammad yustan Curriculum Vitae
Muhammad yustan Curriculum VitaeMuhammad yustan Curriculum Vitae
Muhammad yustan Curriculum Vitae
Muhammad Yustan
 
National Oil Fund of Kazakhstan (Presentation)
National Oil Fund of Kazakhstan (Presentation)National Oil Fund of Kazakhstan (Presentation)
National Oil Fund of Kazakhstan (Presentation)
Kassymkhan Kapparov
 
Manual de preparación y administración de medicamentos inyectables utilizados...
Manual de preparación y administración de medicamentos inyectables utilizados...Manual de preparación y administración de medicamentos inyectables utilizados...
Manual de preparación y administración de medicamentos inyectables utilizados...
MANUEL RIVERA
 
Clase 2 farmacos
Clase 2 farmacosClase 2 farmacos
Clase 2 farmacos
MANUEL RIVERA
 
2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...
2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...
2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...oscargaliza
 
84780 recurso inconstitucionalidade contra reais decretos
84780 recurso inconstitucionalidade contra reais decretos84780 recurso inconstitucionalidade contra reais decretos
84780 recurso inconstitucionalidade contra reais decretososcargaliza
 
Y2e rewardsclub-payplan-presentation
Y2e rewardsclub-payplan-presentationY2e rewardsclub-payplan-presentation
Y2e rewardsclub-payplan-presentation
abnercash
 
Coutinho A Depth Compensation Method For Cross Ratio Based Eye Tracking
Coutinho A Depth Compensation Method For Cross Ratio Based Eye TrackingCoutinho A Depth Compensation Method For Cross Ratio Based Eye Tracking
Coutinho A Depth Compensation Method For Cross Ratio Based Eye Tracking
Kalle
 
Weather Lesson Plans
Weather Lesson PlansWeather Lesson Plans
Weather Lesson Plans
ndwolfe
 
Tell The Difference
Tell The DifferenceTell The Difference
Tell The Difference
javiercarrera
 
Peri porsi
Peri porsiPeri porsi
Peri porsi
Muhammad Yustan
 
Movie it process
Movie it processMovie it process
Movie it process
Sana Samad
 
Ryan Match Moving For Area Based Analysis Of Eye Movements In Natural Tasks
Ryan Match Moving For Area Based Analysis Of Eye Movements In Natural TasksRyan Match Moving For Area Based Analysis Of Eye Movements In Natural Tasks
Ryan Match Moving For Area Based Analysis Of Eye Movements In Natural Tasks
Kalle
 
Clase accesos venosos
Clase accesos venososClase accesos venosos
Clase accesos venosos
MANUEL RIVERA
 
TEMA 5B SER vs ESTAR
TEMA 5B SER vs ESTARTEMA 5B SER vs ESTAR
TEMA 5B SER vs ESTAR
SenoraAmandaWhite
 
Droege Pupil Center Detection In Low Resolution Images
Droege Pupil Center Detection In Low Resolution ImagesDroege Pupil Center Detection In Low Resolution Images
Droege Pupil Center Detection In Low Resolution Images
Kalle
 
Cactus Blossoms!
Cactus Blossoms!Cactus Blossoms!
Cactus Blossoms!
ansiindia
 
Roustan Cover And Filtration
Roustan Cover And FiltrationRoustan Cover And Filtration
Roustan Cover And Filtrationguest4ace713
 

Viewers also liked (20)

Hyves Cbw Mitex Harry Van Wouter
Hyves Cbw Mitex Harry Van WouterHyves Cbw Mitex Harry Van Wouter
Hyves Cbw Mitex Harry Van Wouter
 
Muhammad yustan Curriculum Vitae
Muhammad yustan Curriculum VitaeMuhammad yustan Curriculum Vitae
Muhammad yustan Curriculum Vitae
 
National Oil Fund of Kazakhstan (Presentation)
National Oil Fund of Kazakhstan (Presentation)National Oil Fund of Kazakhstan (Presentation)
National Oil Fund of Kazakhstan (Presentation)
 
Manual de preparación y administración de medicamentos inyectables utilizados...
Manual de preparación y administración de medicamentos inyectables utilizados...Manual de preparación y administración de medicamentos inyectables utilizados...
Manual de preparación y administración de medicamentos inyectables utilizados...
 
Clase 2 farmacos
Clase 2 farmacosClase 2 farmacos
Clase 2 farmacos
 
2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...
2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...
2013 05-08 pc convenio grandes almacéns e liberalización horarios comerciais ...
 
84780 recurso inconstitucionalidade contra reais decretos
84780 recurso inconstitucionalidade contra reais decretos84780 recurso inconstitucionalidade contra reais decretos
84780 recurso inconstitucionalidade contra reais decretos
 
Y2e rewardsclub-payplan-presentation
Y2e rewardsclub-payplan-presentationY2e rewardsclub-payplan-presentation
Y2e rewardsclub-payplan-presentation
 
Coutinho A Depth Compensation Method For Cross Ratio Based Eye Tracking
Coutinho A Depth Compensation Method For Cross Ratio Based Eye TrackingCoutinho A Depth Compensation Method For Cross Ratio Based Eye Tracking
Coutinho A Depth Compensation Method For Cross Ratio Based Eye Tracking
 
Weather Lesson Plans
Weather Lesson PlansWeather Lesson Plans
Weather Lesson Plans
 
Tell The Difference
Tell The DifferenceTell The Difference
Tell The Difference
 
Navarra1
Navarra1Navarra1
Navarra1
 
Peri porsi
Peri porsiPeri porsi
Peri porsi
 
Movie it process
Movie it processMovie it process
Movie it process
 
Ryan Match Moving For Area Based Analysis Of Eye Movements In Natural Tasks
Ryan Match Moving For Area Based Analysis Of Eye Movements In Natural TasksRyan Match Moving For Area Based Analysis Of Eye Movements In Natural Tasks
Ryan Match Moving For Area Based Analysis Of Eye Movements In Natural Tasks
 
Clase accesos venosos
Clase accesos venososClase accesos venosos
Clase accesos venosos
 
TEMA 5B SER vs ESTAR
TEMA 5B SER vs ESTARTEMA 5B SER vs ESTAR
TEMA 5B SER vs ESTAR
 
Droege Pupil Center Detection In Low Resolution Images
Droege Pupil Center Detection In Low Resolution ImagesDroege Pupil Center Detection In Low Resolution Images
Droege Pupil Center Detection In Low Resolution Images
 
Cactus Blossoms!
Cactus Blossoms!Cactus Blossoms!
Cactus Blossoms!
 
Roustan Cover And Filtration
Roustan Cover And FiltrationRoustan Cover And Filtration
Roustan Cover And Filtration
 

Similar to Asp Net Architecture

Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
jinaldesailive
 
ASP.NET Internals
ASP.NET InternalsASP.NET Internals
ASP.NET Internals
GoSharp
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
erdemergin
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
goodfriday
 
Asp.Net Mvc
Asp.Net MvcAsp.Net Mvc
Asp.Net Mvc
micham
 
Api RESTFull
Api RESTFullApi RESTFull
Api RESTFull
Germán Küber
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
Guy Nir
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
Hùng Nguyễn Huy
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
Ilio Catallo
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
nagarajupatangay
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
Dilip Patel
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0ASP.NET MVC 2.0
ASP.NET MVC 2.0
Buu Nguyen
 
Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4
soelinn
 
Day7
Day7Day7
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
John Lewis
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
Fastly
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
Sunil OS
 
Struts Basics
Struts BasicsStruts Basics
Struts Basics
Harjinder Singh
 

Similar to Asp Net Architecture (20)

Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
ASP.NET Internals
ASP.NET InternalsASP.NET Internals
ASP.NET Internals
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Developing ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller PatternDeveloping ASP.NET Applications Using the Model View Controller Pattern
Developing ASP.NET Applications Using the Model View Controller Pattern
 
Asp.Net Mvc
Asp.Net MvcAsp.Net Mvc
Asp.Net Mvc
 
Api RESTFull
Api RESTFullApi RESTFull
Api RESTFull
 
Spring 3.x - Spring MVC
Spring 3.x - Spring MVCSpring 3.x - Spring MVC
Spring 3.x - Spring MVC
 
ASP.NET MVC introduction
ASP.NET MVC introductionASP.NET MVC introduction
ASP.NET MVC introduction
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
Introduction to Struts 1.3
Introduction to Struts 1.3Introduction to Struts 1.3
Introduction to Struts 1.3
 
Spring mvc
Spring mvcSpring mvc
Spring mvc
 
MVC & SQL_In_1_Hour
MVC & SQL_In_1_HourMVC & SQL_In_1_Hour
MVC & SQL_In_1_Hour
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0ASP.NET MVC 2.0
ASP.NET MVC 2.0
 
Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4Retrofit Web Forms with MVC & T4
Retrofit Web Forms with MVC & T4
 
Day7
Day7Day7
Day7
 
Annotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVCAnnotation-Based Spring Portlet MVC
Annotation-Based Spring Portlet MVC
 
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
SoftServe - "ASP.NET MVC як наступний крок у розвитку технології розробки Web...
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
Jsp/Servlet
Jsp/ServletJsp/Servlet
Jsp/Servlet
 
Struts Basics
Struts BasicsStruts Basics
Struts Basics
 

More from Juan Jose Gonzalez Faundez

El embrion humano
El embrion humanoEl embrion humano
El embrion humano
Juan Jose Gonzalez Faundez
 
Arquitectura de Software
Arquitectura de SoftwareArquitectura de Software
Arquitectura de Software
Juan Jose Gonzalez Faundez
 
Ejercicio UML simple
Ejercicio UML simpleEjercicio UML simple
Ejercicio UML simple
Juan Jose Gonzalez Faundez
 
La antigua idea de un gobierno mundial Israelí
La antigua idea de un gobierno mundial IsraelíLa antigua idea de un gobierno mundial Israelí
La antigua idea de un gobierno mundial IsraelíJuan Jose Gonzalez Faundez
 
Orígenes del orden mundial y lo que se viene
Orígenes del orden mundial y lo que se vieneOrígenes del orden mundial y lo que se viene
Orígenes del orden mundial y lo que se viene
Juan Jose Gonzalez Faundez
 
Diseños estructurales usando uml con clases de análisis y modelos de diseño
Diseños estructurales usando uml con clases de análisis y modelos de diseñoDiseños estructurales usando uml con clases de análisis y modelos de diseño
Diseños estructurales usando uml con clases de análisis y modelos de diseño
Juan Jose Gonzalez Faundez
 
Principales estilos arquitectónicos
Principales estilos arquitectónicosPrincipales estilos arquitectónicos
Principales estilos arquitectónicos
Juan Jose Gonzalez Faundez
 
Un problema de diseño Orientado a Objetos
Un problema de diseño Orientado a ObjetosUn problema de diseño Orientado a Objetos
Un problema de diseño Orientado a Objetos
Juan Jose Gonzalez Faundez
 
Fuerza Chile!4
Fuerza Chile!4Fuerza Chile!4

More from Juan Jose Gonzalez Faundez (9)

El embrion humano
El embrion humanoEl embrion humano
El embrion humano
 
Arquitectura de Software
Arquitectura de SoftwareArquitectura de Software
Arquitectura de Software
 
Ejercicio UML simple
Ejercicio UML simpleEjercicio UML simple
Ejercicio UML simple
 
La antigua idea de un gobierno mundial Israelí
La antigua idea de un gobierno mundial IsraelíLa antigua idea de un gobierno mundial Israelí
La antigua idea de un gobierno mundial Israelí
 
Orígenes del orden mundial y lo que se viene
Orígenes del orden mundial y lo que se vieneOrígenes del orden mundial y lo que se viene
Orígenes del orden mundial y lo que se viene
 
Diseños estructurales usando uml con clases de análisis y modelos de diseño
Diseños estructurales usando uml con clases de análisis y modelos de diseñoDiseños estructurales usando uml con clases de análisis y modelos de diseño
Diseños estructurales usando uml con clases de análisis y modelos de diseño
 
Principales estilos arquitectónicos
Principales estilos arquitectónicosPrincipales estilos arquitectónicos
Principales estilos arquitectónicos
 
Un problema de diseño Orientado a Objetos
Un problema de diseño Orientado a ObjetosUn problema de diseño Orientado a Objetos
Un problema de diseño Orientado a Objetos
 
Fuerza Chile!4
Fuerza Chile!4Fuerza Chile!4
Fuerza Chile!4
 

Recently uploaded

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
ArianaBusciglio
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
NelTorrente
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
christianmathematics
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
ArianaBusciglio
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 

Recently uploaded (20)

A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Assignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docxAssignment_4_ArianaBusciglio Marvel(1).docx
Assignment_4_ArianaBusciglio Marvel(1).docx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
MATATAG CURRICULUM: ASSESSING THE READINESS OF ELEM. PUBLIC SCHOOL TEACHERS I...
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
What is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptxWhat is the purpose of studying mathematics.pptx
What is the purpose of studying mathematics.pptx
 
Group Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana BuscigliopptxGroup Presentation 2 Economics.Ariana Buscigliopptx
Group Presentation 2 Economics.Ariana Buscigliopptx
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 

Asp Net Architecture

  • 1. ASP.NET MVC 4 Request Pipeline Lukasz Lysik ASP.NET MVC 4 Study Group 20/08/2013
  • 2. ASP.NET MVC Request Pipeline http://localhost/Controller/Action/1 Hello World!
  • 3. HTTP Modules and HTTP Handlers (Not directly related to ASP.NET MVC but short introduction will help understand further topics.) An HTTP module is an assembly that is called on every request made to your application. An HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. Source: http://msdn.microsoft.com/en-us/library/bb398986%28v=vs.100%29.aspx
  • 4. HTTP Modules and HTTP Handlers HTTP Module 1 HTTP Module 2 HTTP Module 3 HTTP Module 4 HTTP Handler “HttpHandler is where the request train is headed. HttpModule is a station along the way.” Source: http://stackoverflow.com/questions/6449132/http-handler-vs-http-module
  • 5. Typical Uses HTTP Modules Security Statistics and logging Custom headers or footers HTTP Handlers RSS feeds Image server
  • 6. Custom HTTP Modules public class HelloWorldModule : IHttpModule { public void Init(HttpApplication application) { application.BeginRequest += (new EventHandler(this.Application_BeginRequest)); application.EndRequest += (new EventHandler(this.Application_EndRequest)); } private void Application_BeginRequest(Object source, EventArgs e) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; context.Response.Write("<h1><font color=red> HelloWorldModule: Beginning of Request </font></h1><hr>"); } private void Application_EndRequest(Object source, EventArgs e) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; context.Response.Write("<hr><h1><font color=red> HelloWorldModule: End of Request</font></h1>"); } public void Dispose() { } } <configuration> <system.web> <httpModules> <add name="HelloWorldModule" type="HelloWorldModule"/> </httpModules> </system.web> </configuration> Source: http://msdn.microsoft.com/en-us/library/ms227673%28v=vs.85%29.aspx public interface IHttpModule { void Init(HttpApplication context); void Dispose(); }
  • 7. Custom HTTP Handlers using System.Web; public class HelloWorldHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { HttpRequest Request = context.Request; HttpResponse Response = context.Response; Response.Write("<html>"); Response.Write("<body>"); Response.Write("<h1>Hello from a synchronous custom HTTP handler.</h1>"); Response.Write("</body>"); Response.Write("</html>"); } public bool IsReusable { get { return false; } } } public interface IHttpHandler { bool IsReusable { get; } void ProcessRequest(HttpContext context); } <configuration> <system.web> <httpHandlers> <add verb="*" path="*.sample" type="HelloWorldHandler"/> </httpHandlers> </system.web> </configuration> Source: http://msdn.microsoft.com/en-us/library/ms228090%28v=vs.100%29.aspx If you plan to write your own web framework this is good starting point.
  • 8. Existing HTTP Modules and HTTP Handlers HTTP Modules and HTTP Handlers are registered in .NET Framework’s Web.config: c:WindowsMicrosoft.NETFrameworkv4.0.30319Configweb.config Further info: http://programmer.lysik.pl/2013/08/asp-net-http-modules-and-http-handlers.html
  • 9. ASP.NET MVC Request Pipeline 1. Routing 2. Controller execution 3. Action execution 4. Result execution
  • 10. 1. Routing 2. Controller execution 3. Action execution 4. Result execution It all start with UrlRoutingModule.
  • 11. 1. Routing 2. Controller execution 3. Action execution 4. Result execution HTTP Handler HTTP Module 1 HTTP Module 2 UrlRoutingModule RouteTable.Routes MvcHandler
  • 12. 1. Routing 2. Controller execution 3. Action execution 4. Result execution MvcApplication (Global.asax) RouteTable.Routes (System.Web.Routing) System.Web.Mvc.RouteCollectionExtensions
  • 13. 1. Routing 2. Controller execution 3. Action execution 4. Result execution Url IRouteHandler Defaults Constraints DataTokens /Category/{action}/{id} PageRouteHandler … … … /{controller}/{action}/{id} MvcRouteHandler … … … … … … … … RouteTable.Routes (System.Web.Routing)RouteTable.Routes in fact contains: Classes that implement IRouteHandler are not HTTP handlers! But they should return one. System.Web.Mvc.MvcRouteHandler MvcHandler System.Web.Routing.PageRouteHandler Page or UrlAuthFailureHandler System.Web.WebPages.ApplicationParts.ResourceRouteHandler ResourceHandler System.ServiceModel.Activation.ServiceRouteHandler AspNetRouteServiceHttpHandler
  • 14. 1. Routing 2. Controller execution 3. Action execution 4. Result execution HTTP Handler HTTP Module 1 HTTP Module 2 UrlRoutingModule RouteTable.Routes MvcHandler
  • 15. 1. Routing 2. Controller execution 3. Action execution 4. Result execution UrlRoutingModule 1 2 3 4 RemapHandler tells IIS which HTTP handler we want to use. RouteTable.Routes
  • 16. 1. Routing 2. Controller execution 3. Action execution 4. Result execution 1 RouteTable.Routes (System.Web.Routing) RouteCollection public RouteData GetRouteData(HttpContextBase httpContext) { if (this.Count == 0) return (RouteData) null; . . . foreach (RouteBase routeBase in (Collection<RouteBase>) this) { RouteData routeData = routeBase.GetRouteData(httpContext); if (routeData != null) { return routeData; } } return (RouteData) null; } public override RouteData GetRouteData(HttpContextBase httpContext) { RouteValueDictionary values = this._parsedRoute.Match(httpContext.Request.AppRelativeCurrentExecutionFilePath.Substring(2) + httpContext.Request.PathInfo, this.Defaults); RouteData routeData = new RouteData((RouteBase) this, this.RouteHandler); if (!this.ProcessConstraints(httpContext, values, RouteDirection.IncomingRequest)) return (RouteData) null; . . . return routeData; } Route
  • 17. 1. Routing 2. Controller execution 3. Action execution 4. Result execution HTTP Handler HTTP Module 1 HTTP Module 2 UrlRoutingModule RouteTable.Routes MvcHandler 4
  • 18. 1. Routing 2. Controller execution 3. Action execution 4. Result execution MvcHandler Controller Builder 3. Call Execute on created Controller 2. Create Controller using ControllerFactory 1. Get ControllerFactory
  • 19. 1. Routing 2. Controller execution 3. Action execution 4. Result execution MvcHandler private void ProcessRequestInit(HttpContextBase httpContext, out IController controller, out IControllerFactory factory) { . . . string requiredString = this.RequestContext.RouteData.GetRequiredString("controller"); factory = this.ControllerBuilder.GetControllerFactory(); controller = factory.CreateController(this.RequestContext, requiredString); if (controller != null) return; . . . } 2 1 3
  • 20. 1. Routing 2. Controller execution 3. Action execution 4. Result execution factory = this.ControllerBuilder.GetControllerFactory(); controller = factory.CreateController(this.RequestContext, requiredString); 2 ControllerBuilder internal ControllerBuilder(IResolver<IControllerFactory> serviceResolver) { ControllerBuilder controllerBuilder = this; IResolver<IControllerFactory> resolver = serviceResolver; if (resolver == null) resolver = (IResolver<IControllerFactory>) new SingleServiceResolver<IControllerFactory>( (Func<IControllerFactory>) (() => this._factoryThunk()), (IControllerFactory) new DefaultControllerFactory() { ControllerBuilder = this }, "ControllerBuilder.GetControllerFactory"); controllerBuilder._serviceResolver = resolver; } public class CustomControllerFactory : IControllerFactory { public IController CreateController(RequestContext requestContext, string controllerName) { . . . } } public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { IControllerFactory factory = new CustomControllerFactory(); ControllerBuilder.Current.SetControllerFactory(factory); } } Custom Controller Factory MvcHandler
  • 21. 1. Routing 2. Controller execution 3. Action execution 4. Result execution Controller / ControllerBase Dependency Resolution 4. Call InvokeAction on action invoker. 3. Get action invoker. 2. Get action name from RouteData. 1. Call ExecuteCore 0. Execute being called by MvcHandler
  • 22. 1. Routing 2. Controller execution 3. Action execution 4. Result execution 3 ControllerBase Controller : ControllerBase protected override void ExecuteCore() { . . . string requiredString = this.RouteData.GetRequiredString("action"); this.ActionInvoker.InvokeAction(this.ControllerContext, requiredString); . . . }
  • 23. 1. Routing 2. Controller execution 3. Action execution 4. Result execution 3 Controller : ControllerBase protected virtual IActionInvoker CreateActionInvoker() { return (IActionInvoker) DependencyResolverExtensions.GetService<IAsyncActionInvoker>(this.Resolver) ?? DependencyResolverExtensions.GetService<IActionInvoker>(this.Resolver) ?? (IActionInvoker) new AsyncControllerActionInvoker(); } Possible methods of replacing default ActionInvoker: • Assign to ActionInvoker property. • Override CreateActionInvoker method. • Use dependency injection.
  • 24. 1. Routing 2. Controller execution 3. Action execution 4. Result execution 6. Invoke action result 5. Invoke action 4. Bind models. 3. Invoke authorization filters. 2. Find action using descriptor 1. Get controller descriptor (reflection). 0. InvokeAction being called by Controller.ExecuteCore ActionInvoker
  • 25. 1. Routing 2. Controller execution 3. Action execution 4. Result execution ControllerActionInvoker : IActionInvoker this.ActionInvoker.InvokeAction(this.ControllerContext, requiredString); 1 2 3 4 6 5
  • 26. 1. Routing 2. Controller execution 3. Action execution 4. Result execution 4 ControllerActionInvoker : IActionInvoker
  • 27. 1. Routing 2. Controller execution 3. Action execution 4. Result execution 6 ControllerActionInvoker : IActionInvoker
  • 28. 1. Routing 2. Controller execution 3. Action execution 4. Result execution ViewResultBase ViewResultBase ViewResult PartialViewResult
  • 29. 1. Routing 2. Controller execution 3. Action execution 4. Result execution ViewResult PartialViewResult
  • 30. 1. Routing 2. Controller execution 3. Action execution 4. Result execution JsonResult HttpStatusCodeResult