27

I made a MVC4 application with .net 4.5 using razor engine. It works fine when run locally with visual studio.

When I deploy to IIS on windows server 2008 R2(all windows updates done), it appears my bundles do not work and the CCS is not loading. I tried viewing the site on the server, viewed source went to the bundle link for the css, and it loads some css and then there is an IIS error of:

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

What I have tried:

1) Ensured .net 4.5 is installed.
2) Added <modules runAllManagedModulesForAllRequests="true"/> to my web.config
3) Ran %windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_regiis.exe -ir in cmd
4) Checked that my app pool was set to Integrated Mode
5) Checked that it's set to use .net 4

Kyle
  • 32,731
  • 39
  • 134
  • 184

4 Answers4

46

You'll find your answer here: ASP.NET MVC framework 4.5 CSS bundles does not work on the hosting

The short answer is to make sure that your bundle names don't conflict with the names of paths in your sites.

Community
  • 1
  • 1
Rich Turner
  • 10,800
  • 1
  • 51
  • 68
  • 3
    Saved me a lot of time for sure... This fixed my problem, my "~/Content/Template" bundle was conflicting with my physical folder. All I needed to do was to rename the name of my bundle. – covo Dec 11 '12 at 05:16
  • Glad my answer helped you out. This one drove me nuts for several hours one afternoon!! – Rich Turner Mar 20 '13 at 20:57
  • Thank you. You helped me too! Btw, do you know why this occur only with the css bundles? I have the same config in js bundles and it work fine. – Wellington Zanelli Sep 12 '14 at 13:23
7

This solved it for me (solution is from MVC4 HTTP Error 403.14 - Forbidden)

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true"/> 
 </system.webServer>
Community
  • 1
  • 1
silverfox1948
  • 857
  • 10
  • 15
  • 7
    While it might solve the problem, it's like killing a fly with a rocket launcher. `runAllManagedModulesForAllRequests` has performance impacts on your site, as all managed modules will be run for all requests, including requests for static files like images. – René Aug 21 '13 at 10:32
2

Make sure that in your web.config you have enabled anonymous access to your "virtual" bundles paths.

For instance, if your style bundles are like "~/content/blahblah" and your javascript bundles are like "~/scripts/blahblah" you must open anonymoys access to locations "content" and "scripts" like this in your web.config:

<configuration>
 ...
 <location path="content">
  <system.web>
   <authorization>
    <allow users="?" />
   </authorization>
  </system.web>
 </location>

 <location path="scripts">
  <system.web>
   <authorization>
    <allow users="?" />
   </authorization>
  </system.web>
 </location>
 ...
</configuration>

This way, any request to the virtual path "~/content" or "~/scripts" by any user will be granted, and the CSS and JS requests will be served.

Isaac Llopis
  • 432
  • 5
  • 12
1

Another potential problem that causes the 403.14 is the global.asax and/or the web.config not being copied across in your publishing settings or deployment.

Simon
  • 41
  • 4
  • Thank you this helped me to solve the issue. Actually for me the `App_global.asax.compiled` file was missing! – Salar Apr 13 '17 at 07:56