Absolute URL in ASP bundle

前端 未结 6 837
轻奢々
轻奢々 2021-01-07 19:14

I use a jQuery library for Google Maps, and it depends on the Google scripts to be loaded first. I\'d like to be able to include both in the bundle as such:

         


        
6条回答
  •  清歌不尽
    2021-01-07 19:33

    Based on the MVC tutorials, your syntax is incorrect for creating a bundle from a CDN. And as others have said, ensure that you have the bundles.UseCdn = true; property set. Using the example on the MVC site - your code should reflect the following:

    public static void RegisterBundles(BundleCollection bundles)
    {
       bundles.UseCdn = true;   //enable CDN support
       //add link to jquery on the CDN
       var jqueryCdnPath = "http://maps.googleapis.com/maps/api/js?sensor=false&libraries=places";
       bundles.Add(new ScriptBundle("myfoobundle", jqueryCdnPath).Include(
                    "~/Scripts/jquery-{version}.js"));
    }
    

提交回复
热议问题