我已经在本地测试了一个应用程序,在我的本地计算机上呈现正常。当我将它发布到工作中的服务器时,_layout.cshtml不会呈现。从开发人员工具的外观来看,它们可能根本不是任何样式渲染。任何建议,因为我很难过,谷歌没有找到任何类似的情况?我正在使用带Razor的MVC5
我的观点开始
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
编辑版本....我的_layout页面
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - XXXXXXXXXXX</title>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
<meta name="Training Module" content="Website for oreintation and traing modules" />
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<img src="/Images/imgCClogoHorizontal.jpg" style="float: left; padding-top: 10px" />
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div style="padding-left: 30px">
@Html.ActionLink("XXXXXXXXXXXX", "Index", "Module", null, new { @class = "navbar-brand" })
</div>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
@* <li>@Html.ActionLink("Home", "Index", "Home")</li>*@
@* <li>@Html.ActionLink("About", "About", "Home")</li>*@
@* <li>@Html.ActionLink("Orientation Videos", "Index", "Video")</li>*@
</ul>
</div>
</div>
</div>
@Html.Action("Index", "NavigationMenu")
<div class="container body-content">
<div style="display: inline">
<div style="float: left">
@RenderBody()
</div>
<h2> </h2>
</div>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
</body>
</html>
我的bundle.config ...
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js",
"~/Scripts/jquery-ui-{version}.js"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css",
"~/Content/themes/base/jquery-ui.css"));
}
}
}
答案 0 :(得分:2)
您的导航栏内容位于页面的<head>
而不是<body>
。浏览器很可能没有提供任何内容,因为它无法理解。
答案 1 :(得分:2)
_ViewStart.cshtml位于Shared文件夹中,因此我将其移出一个文件夹并放在根文件夹“View”中,然后在我的所有视图中呈现我的布局页面。我必须错误地移动它并且从未注意到它。 SMH !!!!
答案 2 :(得分:0)
您的@ ViewBag.Title是否已填充,您是否能够在屏幕上看到标题。如果是这样,layout.cshtml正在渲染,但您的css / js文件可能不是。您能否检查一下您是否正确捆绑了所有资源。