IIS 7.5 and Razor Site: 500 errors for CSS and JS
Asked Answered
R

6

10

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.

Rox answered 29/3, 2012 at 11:13 Comment(5)
Is the application pool set correctly to ASP.NET v4.0 w/ Integrated mode?Stickleback
It's a custom application pool, which is 4.0 integrated.Rox
Use Failed Request Tracing to understand what is going on: learn.iis.net/page.aspx/266/…Pax
Turn off custom errors on the deployed application, turn on debug mode, try to go directly to one of your CSS files (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.Lapel
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."Rox
R
0

Reinstalling IIS fixed the problem.

Rox answered 30/3, 2012 at 0:16 Comment(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.Wong
G
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.

Gaikwar answered 12/8, 2013 at 17:58 Comment(2)
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 IISDiplopod
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.Cidevant
C
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.

Conics answered 27/4, 2015 at 11:33 Comment(2)
That also was my problem. +1Soulless
Yep, migrating from a 2012 server to a 2019, you need to remove the <staticContent> <mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/> </staticContent>Disembark
W
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>
Wombat answered 15/5, 2018 at 18:9 Comment(2)
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.Hatpin
I agreed, it shouldn't be downvoted - this answer helps me to find the solution (just like @Steve Py the problem was woff2).Cypsela
W
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.
Whitver answered 18/9, 2015 at 18:15 Comment(1)
Access is denied. My company does not allow us to edit user groups.Octangle
R
0

Reinstalling IIS fixed the problem.

Rox answered 30/3, 2012 at 0:16 Comment(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.Wong
H
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.

Halftimbered answered 8/2, 2020 at 18:10 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.