0
構造の角クライアント(プレーンhtml/js/css)を含む空のmvc
テンプレートがあります。
バンドリングと小型化を実現するために、私はthisの記事から手順を実行しました。 マイRegisterBundles方法は、次のルールがあります。ASP.NETバンドル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)を見てください。また、デバッグモードを無効にすることを忘れましたか? –