Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTP Error 403.14 - Forbidden - MVC4 .net 4.5 bundles

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

like image 969
Kyle Avatar asked Nov 20 '12 21:11

Kyle


People also ask

How do you solve this error the Web server is configured to not list the contents of this directory?

To do it, select Start, select Run, type inetmgr.exe, and then select OK. In IIS Manager, expand server name, expand Web sites, and then select the website that you want to change. In the Features view, double-click Directory Browsing. In the Actions pane, select Enable.


4 Answers

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.

like image 69
Rich Turner Avatar answered Oct 25 '22 05:10

Rich Turner


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

<system.webServer>
   <modules runAllManagedModulesForAllRequests="true"/> 
 </system.webServer>
like image 26
silverfox1948 Avatar answered Oct 25 '22 05:10

silverfox1948


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.

like image 2
Isaac Llopis Avatar answered Oct 25 '22 04:10

Isaac Llopis


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.

like image 1
Simon Avatar answered Oct 25 '22 05:10

Simon