我在使用最新mono
的Linux机器上使用MonoDevelop 5.7创建了一个ASP.NET MVC项目。
我的_Layout.cshtml
看起来像这样:
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<title>@ViewBag.Title</title>
@Styles.Render("~/bundle/bootstrap")
</head>
<body>
<header>
<nav 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="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<b><a href="/" class="navbar-brand">EOS</a></b>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li><a href="xml">XML</a></li>
<li><a id="toCheckList" href="checklist">Checklist</a></li>
</ul>
</div>
</div>
</nav>
</header>
<main role="main">
<div ng-view class="cont-main"></div>
</main>
@RenderBody()
<script src="Scripts/angular.min.js"></script>
<script src="Scripts/angular-resource.min.js"></script>
<script src="Scripts/angular-route.min.js"></script>
</body>
</html>
和BundleConfig.cs
看起来像这样:
using System;
using System.Web.Optimization;
namespace Angular2 {
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 StyleBundle ("~/bundle/bootstrap").IncludeDirectory ("~/Content/css/", "*.css") );
}
}
}
我的Global.asax.cs Application_Start()
BundleConfig.RegisterBundles(BundleTable.Bundles);
现在启动服务器时,页面加载正常但css无法访问。
在源代码中,它包含如下:
<link href="/bundle/bootstrap?v=yW6L0KJ49BsmpuPPWZ1xvWLpXC5uk007PYbOr18eA2k1" rel="stylesheet"/>
但是我的html无法使用它,当我点击链接时我得到了:
System.Web.HttpException
The resource cannot be found.
使用下面的堆栈跟踪:
at System.Web.Mvc.DefaultControllerFactory.GetControllerInstance (System.Web.Routing.RequestContext requestContext, System.Type controllerType) [0x00000] in <filename unknown>:0
at System.Web.Mvc.DefaultControllerFactory.CreateController (System.Web.Routing.RequestContext requestContext, System.String controllerName) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.ProcessRequestInit (System.Web.HttpContextBase httpContext, IController& controller, IControllerFactory& factory) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContextBase httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.BeginProcessRequest (System.Web.HttpContext httpContext, System.AsyncCallback callback, System.Object state) [0x00000] in <filename unknown>:0
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest (System.Web.HttpContext context, System.AsyncCallback cb, System.Object extraData) [0x00000] in <filename unknown>:0
at System.Web.HttpApplication+<Pipeline>c__Iterator1.MoveNext () [0x00000] in <filename unknown>:0
at System.Web.HttpApplication.Tick () [0x00000] in <filename unknown>:0
以下是我的项目图片,以查看css文件的位置:
如何让System.Web.Optimizations
正确优化并包含我的资源?