主頁 > 知識庫 > ASP.NET MVC 從IHttp到頁面輸出的實例代碼

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

熱門標(biāo)簽:手機地圖標(biāo)注如何刪除 十堰正規(guī)電銷機器人系統(tǒng) 世紀(jì)佳緣地圖標(biāo)注怎么去掉 寧波自動外呼系統(tǒng)代理 外呼系統(tǒng)代理品牌 辦理400電話證件 巫師3為什么地圖標(biāo)注的財寶沒有 怎么給超市做地圖標(biāo)注入駐店 外呼系統(tǒng)費用一年

復(fù)制代碼 代碼如下:

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);
    }
}       

復(fù)制代碼 代碼如下:

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();
    }
}

復(fù)制代碼 代碼如下:

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);
            }
            IDictionarystring, 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);
}

復(fù)制代碼 代碼如下:

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);
    }
}

您可能感興趣的文章:
  • ASP.NET小結(jié)之MVC, MVP, MVVM比較以及區(qū)別(一)
  • ASP.NET mvc異常處理的方法示例介紹
  • .NET Web開發(fā)之.NET MVC框架介紹
  • ASP.NET MVC3 實現(xiàn)全站重定向的簡單方法
  • ASP.NET小結(jié)之MVC, MVP, MVVM比較以及區(qū)別(二)

標(biāo)簽:天門 嘉興 牡丹江 山西 泰州 景德鎮(zhèn) 通遼

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ASP.NET MVC 從IHttp到頁面輸出的實例代碼》,本文關(guān)鍵詞  ASP.NET,MVC,從,IHttp,到,頁面,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ASP.NET MVC 從IHttp到頁面輸出的實例代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于ASP.NET MVC 從IHttp到頁面輸出的實例代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章