I have an MVC 5 web app that will not resolve images when deploying on a Windows 2012 R2 server using IIS 8 but works fine when running on my local machine.
Getting the following error message in the console:
GET http://test-myurl/Content/Images/gb_uk.png 500 (Internal Server Error)
Here is the hierarchy of the Content folder:
|-Content
|-Images
|-gb_uk.png
|-gb_uk-yellow.png
|-bootstrap.css
|-Site.css
|-custom.css
I have added the style sheets to the bundles in my BundleConfig.cs
like so:
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/Site.css",
"~/Content/custom.css"))
I reference the images in my .css files like so:
background-image: url(Images/gb_uk.png);
I am calling the styles in my _Layout.cshtml
like so:
@Styles.Render("~/Content/css")
It seems like everything is set up fine, but for some reason, when we deploy it to the server, we get error 500 codes when trying to load the images.
We have tried everything on the server to do with permission settings. Tried adding different users to the folder permissions.
We have added BundleTable.EnableOptimizations = true
to the global.aspx file but still no change. Running out of ideas at this point.
Has anyone else had this issue before? I have tried looking around SO and the closest thing I have found is this:
https://stackoverflow.com/a/11386982/2858978
I followed this right down to the T but still it isn't working. The stylesheets load fine but the images are not loading.
I know this is a really old post, but I ran into this problem with a new Server 2019 build. Using Windows Authentication, the app pool identity requires the right "impersonate a client after authentication" to access images such as this. Granting the right to the app pool identity then running iisreset resolved this issue for me.