ASP.NET MVC4中的bundles特性引发服务器拒绝访问(403错误)


where as on my local computer, the source code shows as

<link href="/Content/css/myFile.css" rel="stylesheet"/>
<link href="/Content/css/myFile02.css" rel="stylesheet"/>

So, in the source code view on the server, I clicked onContent/css?v=fxCdHAOgPDvcROxkMfEwGQggO9uCfzckN3PaN8BOIzI1and the browser took me to a 403 - Forbidden: Access is denied.

I am adding the CSS files with the BunldeConfig.cs class

public class BundleConfig
        // For more information on Bundling, visit
        public static void RegisterBundles(BundleCollection bundles)
            bundles.Add(new ScriptBundle("~/bundles/javascript").Include(

            bundles.Add(new StyleBundle("~/Content/css").Include(


My question is, assuming this isn‘t an IT issue with the server (it has been working fine until recently) is there something wrong with my code?


Your problem is that you are using~/Content/cssas a bundle alias innew StyleBundle("~/Content/css"),while this path actually exists.

So when you are requesting<link href="/Content/css?...>you are essentially asking for a directory listing and that is forbidden.

Try using something else, likenew StyleBundle("~/Content/styles").

NOTE:If you do use something like~/Content/stylesas an alias you may have issues with relative urls in your.cssfiles. It may seem odd, but you may better use something like~/Content/Css/someAlias



ASP.NET MVC4中的bundles特性引发服务器拒绝访问(403错误)


下一篇       上一篇