zoukankan      html  css  js  c++  java
  • Asp.Net MVC中不指定View Name时如何返回ActionResult的

    通过ActionResult类查找它的子类,下面是找到的代码:

    //ViewResultBase.cs

        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 viewEngineResult = (ViewEngineResult) null;
          if (this.View == null)
          {
            viewEngineResult = this.FindView(context);
            this.View = viewEngineResult.View;
          }
          TextWriter output = context.HttpContext.Response.Output;
          this.View.Render(new ViewContext(context, this.View, this.ViewData, this.TempData, output), output);
          if (viewEngineResult == null)
            return;
          viewEngineResult.ViewEngine.ReleaseView(context, this.View);
        }
    

     这里可以看到如果View不指定会返回路由中action名相同的view

  • 相关阅读:
    降低大气分
    99999
    88888
    77777
    HandlerThread实现原理
    Android 内存泄漏总结
    Handler实现机制,同步屏障,IdleHandler
    launcher 配置
    微信小程序 上传图片七牛
    微信小程序 跳转传参数 传对象
  • 原文地址:https://www.cnblogs.com/jinzhao/p/2628666.html
Copyright © 2011-2022 走看看