9

For some reason, when I deploy my Razor MVC web site to my Windows 2008 R2 server, I'm getting 500 internal server errors for all CSS and JS. I'm not sure why, because I've done the following:

  • Enabled static content in IIS
  • Enabled anonymous access, with the default ID being the application pool identity and given that identity read/write permission to the folders
  • Ensured my static content handler was setup correctly

What other problems could it be? How can I even debug this to see what the actual error is? Even though I have an Application_Error handler, nothing is getting logged. And IIS logs doesn't give me the error info?

Thanks.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • Is the application pool set correctly to ASP.NET v4.0 w/ Integrated mode? – Ofer Zelig Mar 29 '12 at 12:59
  • It's a custom application pool, which is 4.0 integrated. – Brian Mains Mar 29 '12 at 14:37
  • Use Failed Request Tracing to understand what is going on: http://learn.iis.net/page.aspx/266/troubleshooting-failed-requests-using-tracing-in-iis/ – Matthew Abbott Mar 29 '12 at 15:05
  • Turn off custom errors on the deployed application, turn on debug mode, try to go directly to one of your CSS files (http://mysite.com/Content/Css/styles.css or whatever your direct link is) and see exactly what the yellow screen of death says. I would guess MVC might be trying to 'route' your static content. – Tommy Mar 29 '12 at 15:17
  • The css returns a blank view, and I see the 500 error. The image says "the image X cannot be displayed because it has errors." – Brian Mains Mar 29 '12 at 23:54

6 Answers6

27

Mime-Types were my trouble

I had the same problem. My css and js was not delivered. Server says internal error.

I found out that i added the mimetype for mp4 in the global settings of the iis and also added the mime type in one of my websites as well. That was a problem. This mime-type can only exist in the website or global, not both. I deleted tehe global mimetype and everything worked like it should be.

Hope to help some guys of you.

Tony
  • 271
  • 3
  • 3
  • 1
    Just add the same issue. Thanks. – Brad Sep 16 '14 at 13:14
  • In my case I had to add *.webp* extension in my development machine but when I deployed the solution to a Windows Server 2016 I got the errors described in the question and turns out that webp is set by default on IIS 10 so I removed it from my web.config and the app is working as expected no needed to reinstall IIS – vcRobe Sep 01 '20 at 16:25
  • My issue was related but slightly different. A mime type entry in my web config was causing inherited mime types from the root not to process. Removing the entry fixed the problem. – Uriah Blatherwick Feb 14 '21 at 18:32
13

Just found, that I've added to web.config *.woff MIME for IIS 7.5, so when deploying on IIS8, it's causes static files error. After removing that from web.config everything is fine.

Arman Hayots
  • 2,459
  • 6
  • 29
  • 53
6

I got 500 errors because I added this below to my web.config. After I removed it, I got passed the error.

<staticContent>
  <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
user1366518
  • 174
  • 2
  • 11
  • 1
    I don't know why this was downvoted. This along with Tony's answer pointed to a cause. In my case I'd added woff and woff2 mime types into my IIS instance, however when debugging a different web application it refused to load any/all css and js files. I checked that app's web.config file and found that there was a mimeMap set up for .woff. I commented that out, and presto, the site came up with CSS and JS. Check for mimeMap in the web config and see whether they are actually needed. – Steve Py Mar 28 '19 at 23:10
  • I agreed, it shouldn't be downvoted - this answer helps me to find the solution (just like @Steve Py the problem was woff2). – 1_bug Oct 10 '19 at 08:10
1

To rule out one basic permissions situation, try this:

  1. Select your web site and go into Basic Settings.
  2. Take note of which application pool your site is running under.
  3. Exit out of there and select the Application Pools node.
  4. Find the application pool for your site, and take note of which identity (account) that application pool is running under.

If the account is a specific user identity -- in other words, if it's not a built-in account (such as ApplicationPoolIdentity, Network Service, Local System, etc) then:

  1. Launch your Local Users and Groups.
  2. Find and open the local IIS_IUSRS group.
  3. If the account in question is not a member of the group, add it.
JCDrumKing
  • 101
  • 1
  • 6
0

If you are on your local server and taking this error, please check if you have any missing packages. Catch errors in global.asax and if neccessary reload all packages with;

Update-Package -reinstall

in Package manager console.

Hope it helps.

MonkeyDLuffy
  • 556
  • 7
  • 17
0

Reinstalling IIS fixed the problem.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • 1
    You shouldn't need to take any of the steps you mentioned above. Enabling the Web role and then selecting the ASP.NET role service is all you need. I suspect when you first enabled the web role, you first selected ASP.NET - which then selects IIS (because ASP.NET depends on IS). Doing so in this order you don't get static file handling. By removing the web role and adding it back in the order I stated, static files are served. – RickAndMSFT Mar 30 '12 at 16:29