C# 引导程序不适用于ASP.net MVC绑定
我正在使用引导程序在ASP.net MVC中创建一个简单的登录页面 BundleConfig.csC# 引导程序不适用于ASP.net MVC绑定,c#,asp.net,.net,twitter-bootstrap,asp.net-mvc-4,C#,Asp.net,.net,Twitter Bootstrap,Asp.net Mvc 4,我正在使用引导程序在ASP.net MVC中创建一个简单的登录页面 BundleConfig.cs public class BundleConfig { public static void RegisterBundles(BundleCollection bundles) { bundles.IgnoreList.Clear(); bundles.Add(new ScriptBundle("~/bun
public class BundleConfig
{
public static void RegisterBundles(BundleCollection bundles)
{
bundles.IgnoreList.Clear();
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-1.9.1.js"));
bundles.Add(new ScriptBundle("~/bundles/bootstrapjs").Include(
"~/Scripts/bootstrap.min.js"));
bundles.Add(new StyleBundle("~/Content/bootstrapcss").Include(
"~/Content/bootstrap.min.css",
"~/Content/bootstrap.css"));
}
\u Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>@ViewBag.Title</title>
@Styles.Render("~/Content/bootstrapcss")
</head>
<body>
@RenderBody()
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrapjs")
</body>
</html>
@model ME.Models.Admin.AdminModel
@{
ViewBag.Title = "Index";
Layout = "~/Views/shared/_Layout.cshtml";
}
<center>
<div class="panel panel-primary" style="display:inline-block">
Hello Admin! Please Login
<br />
<table>
<tr>
<td>@Html.LabelFor(m=>m.username)</td>
<td>@Html.TextBoxFor(m=>m.username, new { @class = "form-control" })<br /></td>
</tr>
<tr>
<td>@Html.LabelFor(m=>m.password)</td>
<td>@Html.TextBoxFor(m=>m.password, new { @class = "form-control" })<br /></td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="btn btn-primary" value="Log In" /></td>
</tr>
</table>
</div>
</center>
我在视图文件夹下的共享目录中使用了bundling和_Layout.cshtml
有人能帮忙解决这个问题吗
注意:我没有粘贴模型和控制器的代码,因为我认为这里不需要它
谢谢
protected virtual void Application_Start()
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}
这个不见了。运行正常。浏览器是否加载捆绑包或是否存在任何错误?为什么你要同时使用小型化和普通引导css?请尝试添加
BundleTable.EnableOptimizations=true代码>在创建新捆绑包之前。@BobSwager我是否必须将此添加到BundleConfig类中?是。但我认为你的解决方案应该是这样的:@All。对于/bundles/jquery、/bundles/bootstrapjs/Content/bootstrapcss,我得到了404错误。我必须创建捆绑目录吗??
protected virtual void Application_Start()
{
BundleConfig.RegisterBundles(BundleTable.Bundles);
}