2016-07-01 4 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> 

BundleTable.EnableOptimizations를 true 또는 false로 설정하면이 문제가 발생합니다.

답변

0

저는 bower 및 번들을 사용하는 자습서 인 here과 Microsoft의 자습서 here을 사용했습니다.

BundleConfig.RegisterBundles(BundleTable.Bundles); 

이 또한 내가 mondernizr로 내 구성에서 모더 나이저 맞춤법이 틀린했다 : 무엇 하나 튜토리얼에서 설명되지 않은 것은 클래스가 다음과 같이 파일 Global.asax.cs에 위해 Application_Start에서 호출되어야하는 것이 었습니다.