Asp.net mvc 引导程序4未在Razor视图中渲染
我已从引导3更新到引导4,现在Razor视图将无法正确渲染,如下图所示: 正如您所看到的,所有引导样式都消失了,导航栏也消失了。这与Bootstrap 3很好 这只是MVC项目附带的标准登录页面,所以我没有添加任何花哨的内容 我的包如下:Asp.net mvc 引导程序4未在Razor视图中渲染,asp.net-mvc,razor,bootstrap-4,Asp.net Mvc,Razor,Bootstrap 4,我已从引导3更新到引导4,现在Razor视图将无法正确渲染,如下图所示: 正如您所看到的,所有引导样式都消失了,导航栏也消失了。这与Bootstrap 3很好 这只是MVC项目附带的标准登录页面,所以我没有添加任何花哨的内容 我的包如下: using System.Web; using System.Web.Optimization; namespace FoodSnap { public class BundleConfig { // For more information on
using System.Web;
using System.Web.Optimization;
namespace FoodSnap
{
public class BundleConfig
{
// For more information on bundling, visit https://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"));
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"));
}
}
<!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>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<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>
@*@Html.ActionLink("FoodSnap_TEST", "LogIn", "Account", new { area = "" }, new { @class = "navbar-brand" })*@
</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("Contact", "Contact", "Home")</li>*@
<li>@Html.ActionLink("Pre-Registration", "Index", "PreRegistration")</li>
<li>@Html.ActionLink("Roles", "Index", "Role")</li>
<li>@Html.ActionLink("FoodSnap", "Index", "FoodSnap")</li>
<li>@Html.ActionLink("Review", "Create", "FoodSnap")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - FoodSnap_TEST</p>
</footer>
</div>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
}
在我看来,我的看法如下:
using System.Web;
using System.Web.Optimization;
namespace FoodSnap
{
public class BundleConfig
{
// For more information on bundling, visit https://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"));
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"));
}
}
<!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>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<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>
@*@Html.ActionLink("FoodSnap_TEST", "LogIn", "Account", new { area = "" }, new { @class = "navbar-brand" })*@
</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("Contact", "Contact", "Home")</li>*@
<li>@Html.ActionLink("Pre-Registration", "Index", "PreRegistration")</li>
<li>@Html.ActionLink("Roles", "Index", "Role")</li>
<li>@Html.ActionLink("FoodSnap", "Index", "FoodSnap")</li>
<li>@Html.ActionLink("Review", "Create", "FoodSnap")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - FoodSnap_TEST</p>
</footer>
</div>
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@RenderSection("scripts", required: false)
@ViewBag.Title-我的ASP.NET应用程序
@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/modernizer”)
@*@ActionLink(“FoodSnap_TEST”,“LogIn”,“Account”,new{area=”“},new{@class=“navbar brand”})*@
@*- @Html.ActionLink(“主页”、“索引”、“主页”)
*@
@*- @Html.ActionLink(“关于”、“关于”、“家”)
- @ActionLink(“联系人”、“联系人”、“主页”)
*@
- @ActionLink(“预注册”、“索引”、“预注册”)
- @ActionLink(“角色”、“索引”、“角色”)
- @ActionLink(“FoodSnap”、“Index”、“FoodSnap”)
- @ActionLink(“查看”、“创建”、“食物捕捉”)
@Html.Partial(“_LoginPartial”)
@RenderBody()
&抄袭@DateTime.Now.Year-FoodSnap_测试
@style.Render(“~/Content/css”)
@Scripts.Render(“~/bundles/jquery”)
@Scripts.Render(“~/bundles/bootstrap”)
@RenderSection(“脚本”,必需:false)
我尝试了很多东西,包括CDN,结果都是一样的。以前有人见过吗?引导程序4几乎是对引导程序3的完全重写,这意味着: 引导程序3的代码都与引导程序4不兼容 阅读要迁移的文档: