2017-08-27 1 views
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

+0

は、ここに包含されるいずれかの書き換えルールはありますか?あなたの '.js'ファイルに' html'コンテンツがあるように見えますが、例えば、あなたが 'app.js'を要求するときにサーバーが' index.html'ページを返すことがあります。 –

+0

@KirkLarkinはい、あります。トピックを更新しました。これのための修正はありますか? – Vendor

+0

あなたが参照したバンドルに関する投稿に、この[補足回答](https://stackoverflow.com/questions/22345420/bundling-and-minification-without-asp-net-mvc/28738462#28738462)を見てください。また、デバッグモードを無効にすることを忘れましたか? –

答えて

0

私はIIS(IIS =>あなたのウェブサイト=>モジュール)で "バンドルモジュール"を持っていなかったし、角プロジェクトでWebGreaseパッケージの問題もありました。だから、解決策は:パッケージマネージャコンソールで
1.実行:Update-package webgrease
2. web.configでセクションを持っていることを確認してください。

<system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"> 
     <remove name="BundleModule"/> 
     <add name="BundleModule" type="System.Web.Optimization.BundleModule"/> 
    </modules> 
</system.webServer> 
関連する問題