ASP.NET MVC

Post on 06-May-2015

3.807 views 3 download

Transcript of ASP.NET MVC

ASP.NET MVC Under the Hood

Paul StovellReadify

Agenda

ASP.NET MVC 101

ASP.NET MVC Pipeline Controller Factories Action Invokers Model Binders Action Filters Action Results View Engines

Introducing ASP.NET MVC

View

Model

Controller

GET /

ASP.NET MVC Pipeline

ASP.NET Request Pipeline

Internet

Module Module Module

Handler

Handler

Handler

Handler

Handler

public interface IHttpHandler{ void ProcessRequest( HttpContext context);

bool IsReusable { get; }}

Web Forms<%@ Page Language="C#" CodeBehind="Default.aspx.cs" Inherits="Sample.DefaultPage" %>

<div> <asp:TextBox runat="server" /></div>

namespace ASP { public class default_aspx : Sample.DefaultPage, System.Web.IHttpHandler {

PreInitInit

InitCompletePreLoad

LoadControl EventsLoadComplete

PreRenderSaveStateComplete

RenderUnload

MVC PipelineIntern

et

Module

MvcHandler

Module

RoutingController Factory

Controller.Execute()

Action Invoker

View Engine

MVC Pipeline: Controller Factories

public interface IControllerFactory { IController CreateController( RequestContext requestContext, string controllerName);

void ReleaseController( IController controller); }

MVC Pipeline: Controllers

public interface IController{ void Execute( RequestContext requestContext);}

Controller IActionInvoker

MVC Pipeline: Action Invoker

public interface IActionInvoker{ bool InvokeAction( ControllerContext controllerContext, string actionName);}

Action Invoker

MVC Pipeline: Action Invoker

Find Action

Authorization Filters

Request Validation

Model Binders

Invoke

Execute Action Result

Pre-Action Filters

Post-Action Filters

MVC Pipeline: Model Binders

public interface IModelBinder{ object BindModel( ControllerContext controllerContext, ModelBindingContext bindingContext);}

MVC Pipeline: Action Filters

public interface IActionFilter{ void OnActionExecuting( ActionExecutingContext filterContext);

void OnActionExecuted( ActionExecutedContext filterContext);}

MVC Pipeline: Action Results

public abstract class ActionResult{ public abstract void ExecuteResult( ControllerContext context);}

ViewResultBase

ViewResultPartialViewRes

ult

RedirectResult

JsonResult FileResult

MVC Pipeline: View Engines

public interface IViewEngine{ ViewEngineResult FindPartialView( ControllerContext controllerContext, string partialViewName, bool useCache);

ViewEngineResult FindView( ControllerContext controllerContext, string viewName, string masterName, bool useCache);

void ReleaseView( ControllerContext controllerContext, IView view);}

Summary

Q&A

www.asp.net/mvchttp://www.mokosh.co.uk/page/VsCommands.aspx

Paul Stovellpaul.stovell@readify.net

www.paulstovell.com