ojek
ojek

Reputation: 10056

ASP.MVC Bundles - how to define them correctly?

I have something like this:

bundles.Add(new StyleBundle("~/Content/Styles/Default/Forums").Include("~/Content/Styles/Default/Forums/Main.css",
                                                                           "~/Content/Styles/Default/Forums/Slider.css"));

Now, when i release my application and run it, it creates a link like this:

<link href="/Content/Styles/Default/Forums?v=8vn0bgRpB8BncmaT_onrpNlXa4t9ydK6_Fep81xhhm01" rel="stylesheet"/>

Which refers to my site directory, and access to that is disabled. But ASP doesn't let me specify files outside of the application, then how can I do it properly?

Upvotes: 2

Views: 1708

Answers (1)

dan radu
dan radu

Reputation: 2782

The virtual path in the StyleBundle constructor doesn't have to match an existing path in your application:

bundles.Add(new StyleBundle("~/Content/css").Include(
  "~/Content/Styles/Default/Forums/Main.css",
  "~/Content/Styles/Default/Forums/Slider.css"));

If you want to use external files, you can use the CDN path on the bundle (you need to set the UseCDN property to true):

bundles.UseCdn = true;

bundles.Add(new StyleBundle("~/Content/css", "<CDN Path>").Include(
  "<CDN Path>/Main.css",
  "<CDN Path>/Slider.css"));

Upvotes: 4

Related Questions