通过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
本文转自today4king博客园博客,原文链接:http://www.cnblogs.com/jinzhao/archive/2012/08/08/2628666.html,如需转载请自行联系原作者