16

I have a problem where i get this error in the developer console, for all css, image and js files:

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

The file name and path looks fine and it's happening for ALL resources. The project is an ASP.NET MVC project, which my co-worker can build and run just fine, without these errors. The project is located in my usual projects folder and i have never experienced this problem before. I also checked the folder permissions, and i am completely clueless as to why this is happening.

The resources are bundled, but if i create the links to the resources manually, it throws the same errors in the developer console.

Have anyone ever tried something like this before?

Log: Log

Tracelog: Tracelog

BundleConfig.cs

public class BundleConfig
    {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js",
                        "~/Scripts/jquery.min.js",
                        "~/Scripts/jquery.simplemodal.js",
                        "~/Scripts/jquery.flot.min.js",
                        "~/Scripts/jquery.flot.categories.min.js"
                        ));

            bundles.Add(new ScriptBundle("~/bundles/language").Include(
                "~/Language/english.js",
                "~/Language/spanish.js",
                "~/Language/french.js"
               ));


            bundles.Add(new StyleBundle("~/Content/css").Include(
                "~/Styles/StyleNuheat.css",
                "~/Styles/buttons.css",
                "~/Styles/energy.css",
                "~/Styles/modalwindow.css",
                "~/Styles/dropdown.css",
                "~/Styles/jquery-ui.css"
                ));

            bundles.Add(new ScriptBundle("~/bundles/thermostat").Include(
                "~/Scripts/appl_thermostats.js",
                "~/Scripts/appl_thermostat_details.js",
                "~/Scripts/appl_schedule.js"
                ));

            bundles.Add(new ScriptBundle("~/bundles/general").Include(
                "~/Scripts/appl_supporter.js",
                "~/Scripts/appl_master.js",
                "~/Scripts/appl_navigation.js",
                 "~/Scripts/appl_general.js"
                ));

            bundles.Add(new ScriptBundle("~/bundles/energy").Include(
                "~/Scripts/appl_energy.js", 
                "~/Scripts/jquery-ui.js"

                ));

            bundles.Add(new ScriptBundle("~/bundles/useraccount").Include(
                "~/Scripts/appl_useraccount.js"
                ));
            bundles.Add(new ScriptBundle("~/bundles/groups").Include(
                "~/Scripts/appl_groups.js"
                ));
            bundles.Add(new ScriptBundle("~/bundles/login").Include(
                "~/Scripts/appl_login.js"
                ));


        }
    }
Teilmann
  • 2,146
  • 7
  • 28
  • 57
  • The linked question has nothing to do with my problem at all. He is trying to make an Ajax call and in my case, the server doesn't load any resource files at all.. – Teilmann Sep 09 '15 at 09:21
  • I'm afraid there is not enough information to help here. Assuming you are running IIS or IIS Express, try to enable Failed Request Tracing to see what's going on on the server - https://www.iis.net/configreference/system.webserver/tracing/tracefailedrequests – Sergey Rybalkin Sep 09 '15 at 09:22
  • I agree, but i didn't know what else to provide really. I'll look into it. thanks – Teilmann Sep 09 '15 at 09:23
  • @SergeyRybalkin It would seem that Failed Request Tracing was already enabled, but i can conclude nothing from it, im afraid... – Teilmann Sep 09 '15 at 09:31
  • Can you show your bundle configs? – Sirwan Afifi Sep 09 '15 at 09:35
  • I have added it to the question – Teilmann Sep 09 '15 at 09:39
  • @Thomas, you've attached the wrong trace log - this one is for request to http://localhost:51152/ which returned 200 OK. Please attach tracelog for request that returned code 500 – Sergey Rybalkin Sep 09 '15 at 10:04
  • @SergeyRybalkin I have changed the link to another tracelog with error code 500 – Teilmann Sep 09 '15 at 10:08
  • @ThomasTeilmann, your Google drive link says "You need permission" – Sergey Rybalkin Sep 09 '15 at 10:10
  • @SergeyRybalkin Sorry! i went on my lunch break, ill fix it ASAP – Teilmann Sep 09 '15 at 10:32
  • @SergeyRybalkin Did that help? – Teilmann Sep 09 '15 at 10:33
  • @ThomasTeilmann yes, thanks. I've posted an answer below – Sergey Rybalkin Sep 09 '15 at 10:39
  • Not that it's entirely relevant to your question, but use `~/Scripts/jquery-{version}.js` or `~/Scripts/jquery.min.js` in your bundle, not both. If you're using the jQuery NuGet package, use the former. Otherwise, you're eventually going to experience jQuery load errors, as you'll wind up loading jQuery twice if there is both a `jquery-2.whatever.min.js` and a `jquery.min.js` file in your scripts directory.. – Tieson T. Sep 13 '15 at 04:05

5 Answers5

21

According to the TraceLog file that you provided you have a problem in your web.config file. An exception message is C:\Users\teilmann\source\Nuheat\oj.web\oj.web.main\web.config ( 112) :Cannot add duplicate collection entry of type "mimeMap" with unique key attribute "fileExtension" set to ".json"

Most likely you have a MIME type defined for JSON files both on the WebSite and application level

Sergey Rybalkin
  • 3,004
  • 22
  • 26
  • 1
    I located the mimeMap .json in the projects web config, and commented it out. That worked! I have no idea why my co-worker have no problems running it.. Thanks! – Teilmann Sep 09 '15 at 10:44
  • 1
    Probably he doesn't have this defined on the WebSite level. You two should agree on where to define JSON MIME type, otherwise one of you will always have a problem with this. – Sergey Rybalkin Sep 09 '15 at 10:45
  • 1
    For me the issue was a woff2 mimeMap being setup in the web config file (which 2013 needed and apparently 2015 doesn't) – Stephen Sep 10 '16 at 14:13
  • My issue was with the mimeMap put in from TypeScript! I removed this: ' ' From my Web.config and now the icons show! – Adam Nov 03 '16 at 20:47
  • @Airborne But why would you want to serve *.ts files to the browser? Shouldn't you compile them to JavaScript first? – Sergey Rybalkin Nov 05 '16 at 09:59
  • @SergeyRybalkin Yes, all I am saying at some point in time that line got added without my knowledge to the config file. – Adam Nov 07 '16 at 15:27
  • In my case it was also this entry I needed in VS 2013. . After Moving to VS 2015 I had to delete it from the web.config. – Karl Mar 20 '17 at 11:23
  • Never found the real error in my logs, but re-creating web.config solved my problem – RonaldPaguay Apr 11 '22 at 04:58
5

I am working on Win2012 server and using IIS 8.5 .

Please check "staticcontent" section in web config. There is a line in our config for mimemap and mimetype .

mimeMap fileExtension=".woff" mimeType="application/x-woff"

I commented this line and it started working. 500 error got resolved for me.

Satyajeet
  • 69
  • 1
  • 6
2

I fixed it by removing the content of the staticContent in my web.config. IIS 10 was complaining about having duplicate fileExtentions keys in web.cofing.

1

Most likely it's beacuse of permission, Make sure that your folder has a right permission for IIS_IUSRS account.

Sirwan Afifi
  • 10,654
  • 14
  • 63
  • 110
  • Do you have any idea why this could suddenly be a problem, and for this project only? I have all my projects in this folder.. Also adding permissions for this account didn't help much, im afraid. thanks though – Teilmann Sep 09 '15 at 09:32
  • @ThomasTeilmann Actually It sounds like a permissions error, By the way, you can also check your bundle configuration. http://stackoverflow.com/questions/18423253/mvc-bundling-failed-to-load-resource – Sirwan Afifi Sep 09 '15 at 09:37
  • It's added to the question – Teilmann Sep 09 '15 at 09:39
  • Please just remember, that this project build and run just fine on several co-workers computers, so it shouldn't really be an issue with the bundle config – Teilmann Sep 09 '15 at 09:40
  • How do i then grant the right permissions for that account? – Teilmann Sep 09 '15 at 09:47
  • Follow this link: http://stackoverflow.com/questions/5388698/mvc-i-have-deployed-my-application-but-css-only-works-when-i-log-in?answertab=active#tab-top – Sirwan Afifi Sep 09 '15 at 10:34
0

If the css is not loaded, use the developer tool in the Chrome to see the css name. Navigate to that css in the browser- If the custom error mode is turned off, it will show the actual error. In my case, duplicate mimetype was present.

Dev
  • 1,451
  • 20
  • 30