0
我有一个空的mvc
模板与Angular客户端(普通html/js/css)与following结构。
为了实现捆绑和缩小,我做了this文章中的步骤。 我RegisterBundles方法有以下规则:ASP.NET Bundle AngularJS
public static void RegisterBundles(BundleCollection bundles)
{
//bundles.Add(new ScriptBundle("~/bundles/js").IncludeDirectory(
// "/App/","*.js", true));
bundles.Add(new StyleBundle("~/bundles/styles.css").Include(
"/Content/*.css"));
bundles.Add(new ScriptBundle("~/bundles/app.js").Include(
"~/App/app.modules.js")
.IncludeDirectory("~/App/Components/", "*Module.js", true)
.IncludeDirectory("~/App/Components/", "*Service.js", true)
.IncludeDirectory("~/App/Components/", "*Controller.js", true));
}
要连结这些包,我要把它放到的Index.html:
<link href="/bundles/styles.css" rel="stylesheet"/>
<script src="/bundles/app.js" type="text/javascript" language="text/javascript"></script>
更新
我更新了重写规则在web.config文件
<system.webServer>
<httpErrors errorMode="Detailed" />
<asp scriptErrorSentToBrowser="true"/>
<rewrite>
<rules>
<rule name="AngularJS Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/bundles/styles$" ignoreCase="true"/>
<add input="{REQUEST_URI}" negate="true" pattern="^/bundles/app$" ignoreCase="true"/>
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
而我仍然没有得到捆绑。我得到404找不到和this
是否有这里涉及任何重写规则?虽然看起来你的'.js'文件中包含'html'内容,例如,当你询问'app.js'时,服务器可能返回'index.html'页面。 –
@KirkLarkin是的,有。更新了主题。有没有解决这个问题? – Vendor
看看这个[补充答案](https://stackoverflow.com/questions/22345420/bundling-and-minification-without-asp-net-mvc/28738462#28738462)到捆绑你引用的帖子。另外,你还记得禁用调试模式吗? –