激情久久久_欧美视频区_成人av免费_不卡视频一二三区_欧美精品在欧美一区二区少妇_欧美一区二区三区的

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - ASP.NET教程 - ASP.NET MVC 從IHttp到頁面輸出的實例代碼

ASP.NET MVC 從IHttp到頁面輸出的實例代碼

2019-11-17 13:16asp.net教程網 ASP.NET教程

MVCHandler應該算是MVC真正開始的地方。MVCHandler實現了IHttpHandler接口,ProcessRequest便是方法入口

代碼如下:


MVCHandler : IHttpHandler
void IHttpHandler.ProcessRequest(HttpContext httpContext)
{
    this.ProcessRequest(httpContext);
}

 

protected virtual void ProcessRequest(HttpContext httpContext)
{
    HttpContextBase base2 = new HttpContextWrapper(httpContext);
    this.ProcessRequest(base2);
}

protected internal virtual void ProcessRequest(HttpContextBase httpContext)
{
    IController controller;
    IControllerFactory factory;
    this.ProcessRequestInit(httpContext, out controller, out factory);
    try
    {
        controller.Execute(this.RequestContext);
    }
    finally
    {
        factory.ReleaseController(controller);
    }
}        

 

 

復制代碼代碼如下:


Controller : ControllerBase : IController
void IController.Execute(RequestContext requestContext)  //------>Controller
{
    this.Execute(requestContext);
}

 

protected virtual void Execute(RequestContext requestContext)   //------>ControllerBase
{
    if (requestContext == null)
    {
        throw new ArgumentNullException("requestContext");
    }
    if (requestContext.HttpContext == null)
    {
        throw new ArgumentException(MvcResources.ControllerBase_CannotExecuteWithNullHttpContext, "requestContext");
    }
    this.VerifyExecuteCalledOnce();
    this.Initialize(requestContext);
    using (ScopeStorage.CreateTransientScope())
    {
        this.ExecuteCore();
    }
}

protected override void ExecuteCore()   //------>Controller
{
    this.PossiblyLoadTempData();
    try
    {
        string requiredString = this.RouteData.GetRequiredString("action");
        if (!this.ActionInvoker.InvokeAction(base.ControllerContext, requiredString))   //public IActionInvoker ActionInvoker { get; set; }
        {
            this.HandleUnknownAction(requiredString);
        }
    }
    finally
    {
        this.PossiblySaveTempData();
    }
}

 

 

復制代碼代碼如下:


ControllerActionInvoker : IActionInvoker
public virtual bool InvokeAction(ControllerContext controllerContext, string actionName)
{
    if (controllerContext == null)
    {
        throw new ArgumentNullException("controllerContext");
    }
    if (string.IsNullOrEmpty(actionName))
    {
        throw new ArgumentException(MvcResources.Common_NullOrEmpty, "actionName");
    }
    ControllerDescriptor controllerDescriptor = this.GetControllerDescriptor(controllerContext);
    ActionDescriptor actionDescriptor = this.FindAction(controllerContext, controllerDescriptor, actionName);
    if (actionDescriptor == null)
    {
        return false;
    }
    FilterInfo filters = this.GetFilters(controllerContext, actionDescriptor);
    try
    {
        AuthorizationContext context = this.InvokeAuthorizationFilters(controllerContext, filters.AuthorizationFilters, actionDescriptor);
        if (context.Result != null)
        {
            this.InvokeActionResult(controllerContext, context.Result);
        }
        else
        {
            if (controllerContext.Controller.ValidateRequest)
            {
                ValidateRequest(controllerContext);
            }
            IDictionary<string, object> parameterValues = this.GetParameterValues(controllerContext, actionDescriptor);
            ActionExecutedContext context2 = this.InvokeActionMethodWithFilters(controllerContext, filters.ActionFilters, actionDescriptor, parameterValues);
            this.InvokeActionResultWithFilters(controllerContext, filters.ResultFilters, context2.Result);
        }
    }
    catch (ThreadAbortException)
    {
        throw;
    }
    catch (Exception exception)
    {
        ExceptionContext context3 = this.InvokeExceptionFilters(controllerContext, filters.ExceptionFilters, exception);
        if (!context3.ExceptionHandled)
        {
            throw;
        }
        this.InvokeActionResult(controllerContext, context3.Result);
    }
    return true;
}

 

protected virtual void InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult)
{
    actionResult.ExecuteResult(controllerContext);
}

 

 

復制代碼代碼如下:


ActionResult
public override void ExecuteResult(ControllerContext context)
{
    if (context == null)
    {
        throw new ArgumentNullException("context");
    }
    if (string.IsNullOrEmpty(this.ViewName))
    {
        this.ViewName = context.RouteData.GetRequiredString("action");
    }
    ViewEngineResult result = null;
    if (this.View == null)
    {
        result = this.FindView(context);   //ViewEngineResult
        this.View = result.View;    //IView接口    
    }
    TextWriter output = context.HttpContext.Response.Output;
    ViewContext viewContext = new ViewContext(context, this.View, this.ViewData, this.TempData, output);
    this.View.Render(viewContext, output);
    if (result != null)
    {
        result.ViewEngine.ReleaseView(context, this.View);
    }
}

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 国产亚洲精品久久 | 精精国产xxxx视频在线播放7 | 久久久久久久黄色片 | 欧美亚洲国产一区 | 黄色影院在线 | va视频在线| 久久久久久久91 | 伊人午夜视频 | 久久久久久久久久久一区 | 国产九九热视频 | 澳门一级淫片免费视频 | 国产一区二区视频在线播放 | 91av在线国产 | 欧美日韩国产成人在线观看 | 国产99页| 成人福利在线免费观看 | 久久久久久久午夜 | 欧美一级做性受免费大片免费 | 久久精品日韩一区 | 国产一区二区免费看 | 国产剧情在线观看一区二区 | 国产成人免费精品 | 久久人人爽人人爽人人片av免费 | 羞羞色院91精品网站 | 手机av免费在线 | 91国内精品久久久久免费影院 | 免费在线观看毛片 | 亚洲电影免费观看国语版 | 九九热久久免费视频 | 一区二区三区四区五区中文字幕 | 欧洲精品久久久久69精品 | 一级黄片毛片免费看 | 欧美国产免费 | 日本网站一区二区三区 | 91a在线观看 | 九九热免费精品视频 | 黄色免费入口 | av免费大全 | 成人在线视频国产 | 欧美日韩在线播放 | 狠狠99 |