2016-07-01 28 views
1

私は自分の足をASP.NET MVCで濡らしています。ここでバンドルされたスクリプトが正しくレンダリングされない

は私BundleConfig.csの内容は

bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
    "~/bower_components/jquery/dist/jquery.js" 
)); 

bundles.Add(new ScriptBundle("~/bundles/jquery-ui").Include(
    "~/bower_components/jquery-ui/ui/core.js", 
    "~/bower_components/jquery-ui/ui/widget.js", 
    "~/bower_components/jquery-ui/ui/position.js", 
    "~/bower_components/jquery-ui/ui/menu.js", 
    "~/bower_components/jquery-ui/ui/autocomplete.js" 
)); 

bundles.Add(new ScriptBundle("~/bundles/mondernizr").Include(
    "~/Scripts/modernizr-*" 
)); 

bundles.Add(new StyleBundle("~/Content/css").Include(
    "~/bower_components/bootstrap/dist/css/bootstrap.css", 
    "~/Content/PagesList.css", 
    "~/Content/Site.css", 
    "~/bower_components/font-awesome/css/font-awesome.css" 
)); 

されており、ここでは、私は頭の中でスクリプトやCSSをレンダリングしたい私の_layoutのHTML内の領域です。

@Styles.Render("~/Content/css") 
@Scripts.Render("~/bundles/jquery", "~/bundles/jquery-ui") 
@Scripts.Render("~/bundles/modernizr") 

は、私の知る限り承知しているように私はちょうど私が出力するスクリプト/リンクタグの完全なリストまたはバンドルされたバージョンのいずれかをそれを得るためにバンドルで指定されたのと同じ相対パスを使用する必要があります。代わりに、私が期待していた最後のバージョン文字列がなくても、次のようになります。

<link href="/Content/css" rel="stylesheet"/> 
<script src="/bundles/jquery"></script> 
<script src="/bundles/jquery-ui"></script> 
<script src="/bundles/modernizr"></script> 

私がtrueまたはfalseに設定BundleTable.EnableOptimizationsを持っている場合、これは関係なく、発生します。

答えて

0

私は、bowerとバンドルを使用するためのチュートリアルhereと、マイクロソフトのチュートリアルhereに従っていました。

BundleConfig.RegisterBundles(BundleTable.Bundles); 

はまた、私はmondernizrとしての私の構成でmodernizrスペルミスしていた:何のいずれかのチュートリアルで説明されていなかったことは、クラスには、以下を含むファイルGlobal.asax.csでのApplication_Startで呼び出さなければならないことでした。

関連する問題