这是我的 _ViewStart.cshtml:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
这是我的 _Layout.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- Lots of tags for dependencies -->
</head>
<body>
<div class="container body-content">
@RenderBody()
<div class="divider row top-buffer"></div>
<footer>
<p>© @DateTime.Now.Year - MyApp</p>
</footer>
</div>
</body>
</html>
这是我的 Index.cshtml:
@Html.RenderApiEndpoints()
<script type="text/javascript" src="~/Content/index.js"></script>
<div ng-app="app">
<div ng-view ></div>
</div>
我正在获取 Index.cshtml,例如:
public class HomeController : Controller
{
[Route("")]
public ActionResult Index()
{
return View();
}
}
因为我在 Angular 中使用客户端路由$routeProvider
,所以我总是在 Index.cshtml 中。此外,我不需要布局,我只需要我的 Index.cshtml。
在浏览器中访问 localhost 时,如何避免使用布局文件并直接从我的 Index.cshtml 开始?
你可以设为Layout
null 然后你就会看到Index.cshtml view
@{
Layout = null;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句