62,025
社区成员
发帖
与我相关
我的任务
分享
public class DefaultController : Controller
{
//
// GET: /Default/
public ActionResult Index()
{
ViewBag.Title2 = "test";
return View();
}
public ActionResult Index2()
{
return View();
}
}
Index
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<link href="~/Content/bootstrap-theme.min.css" rel="stylesheet" />
<script src="~/Scripts/jquery-3.1.1.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
</head>
<body>
<div class=" container">
这是Index
@ViewBag.Title2
@{Html.RenderAction("Index2");}
</div>
</body>
</html>
Index2
@{
Layout = null;
}
<div>
<hr />
这里是Index2
@ViewBag.Title2
</div>
public ActionResult Index2()
{
string indexHtml = index 调用方法渲染成html并返回。
return Content( indexHtml );
}
public ActionResult Index2()
{
return View("Index"); //如果不在同一文件夹下,Index可能要写全称
}