title: ASP.NET MVC application gives Internal Server Error only when viewed in Firefox
body: <p>(I'm new to .Net and the Microsoft world in general, coming from a Java and Tomcat background, so please bear that in mind.)</p>
  
  <p>I'm working on my first .Net application, using Visual Studio 2013, C#, .Net 4.5, MVC 5, and EF 6. It's a fairly simple web-based application, using Windows authentication and Active Directory groups for authorization to do fairly basic CRUD operations on a table in a SQL Server database.</p>
  
  <p>I haven't deployed the application yet. I'm still developing it and testing it out on my PC (running Windows 7). When I hit Ctrl-F5 to test out the application in Internet Explorer or in Google Chrome, everything works fine.</p>
  
  <p>However, if I tell Visual Studio to access it in Firefox instead, it displays the page <strong>WITHOUT</strong> any CSS or JavaScript. I can click links within the application and navigate to the various pages, which all work fine. They're just displayed without any CSS or working JavaScript. When I manually try to view one of the CSS or JavaScript files, I get an internal server error (HTTP Error 500). Checking the log file shows a status code 500 for each of the CSS and JavaScript files the page was trying to load.</p>
  
  <p>I'm mystified, because it works fine from Internet Explorer and from Chrome. How could using a different web browser cause this internal server error?</p>
  
  <p>I'd post some of the code, but at this point I've no idea what would be useful to see. (I could show what sort of additional information IIS Express is logging, if any, but I'm not sure where to find that, other than the line that shows the status code 500.)</p>
  
  <p>At some point fairly early in development, I realized that I had named some database field "version" when I wanted it to be named "Version" (capitalized). I did a global find/replace in the entire solution on that string, rather than doing a rename of the field. It's possible that something important was borked by that process, but I've done a global find on "Version" (and on "version") and haven't found anything of note.</p>
  
  <p>If I absolutely have to, I'll probably just re-create the project from scratch and hope that I don't copy/paste the same problem (or a new one) into the new project, but I'm hoping someone can come up with something easier to try first.</p>
  
  <h1>UPDATE</h1>
  
  <p>Here is the start of Views/Shared/_Layout.cshtml:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8" /&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1.0"&gt;
      &lt;title&gt;@ViewBag.Title - Experiment 626&lt;/title&gt;
      @Styles.Render("~/Content/css")
      @Scripts.Render("~/bundles/modernizr")
  &lt;/head&gt;
  </code></pre>
  
  <p>Here is App_Start\BundleConfig.cs:</p>
  
  <pre><code>using System.Web;
  using System.Web.Optimization;
  
  namespace Experiment626
  {
      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"));
  
              bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                          "~/Scripts/jquery.validate.min.js",
                          "~/Scripts/jquery.validate.unobtrusive.min.js"));
  
              // Use the development version of Modernizr to develop with and learn from. Then, when you're
              // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
              bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                          "~/Scripts/modernizr-*"));
  
              bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                        "~/Scripts/bootstrap.js",
                        "~/Scripts/respond.js"));
  
              bundles.Add(new StyleBundle("~/Content/css").Include(
                        "~/Content/bootstrap-theme.css",
                        "~/Content/site.css"));
          }
      }
  }
  </code></pre>
  
  <h1>UPDATE</h1>
  
  <p>Looking in Firebug, for each CSS or JavaScript file, the request and response headers look like this:</p>
  
  <h2>Request Header</h2>
  
  <pre><code>GET /Content/site.css HTTP/1.1
  Host: localhost:6365
  User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0
  Accept: text/css,*/*;q=0.1
  Accept-Language: en-US,en;q=0.5
  Accept-Encoding: gzip, deflate
  DNT: 1
  Referer: http://localhost:6365/
  Connection: keep-alive
  Pragma: no-cache
  Cache-Control: no-cache
  </code></pre>
  
  <h2>Response Header</h2>
  
  <pre><code>HTTP/1.1 500 Internal Server Error
  Cache-Control: private
  Content-Type: text/html; charset=utf-8
  Server: Microsoft-IIS/8.0
  X-SourceFiles: =?UTF-8?B?QzpcVXNlcnNcV2FsbHkuSGFydHNob3JuXFZpc3VhbCBTdHVkaW8gMjAxM1xQcm9qZWN0c1xFeHBlcmltZW50NjI2XEV4cGVyaW1lbnQ2MjZcQ29udGVudFxzaXRlLmNzcw==?=
  Persistent-Auth: true
  X-Powered-By: ASP.NET
  Date: Tue, 25 Feb 2014 21:13:50 GMT
  Content-Length: 5870
  </code></pre>
  
  <h1>UPDATE</h1>
  
  <p>For comparison, here is the request header when using Chrome:</p>
  
  <pre><code>Accept:text/css,*/*;q=0.1
  Accept-Encoding:gzip,deflate,sdch
  Accept-Language:en-US,en;q=0.8
  Cache-Control:no-cache
  Connection:keep-alive
  Host:localhost:6365
  Pragma:no-cache
  Referer:http://localhost:6365/
  User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
  </code></pre>
  
  <h1>UPDATE</h1>
  
  <p>In the default error page displayed by IIS, there is a Detailed Error Information section, which contains this:</p>
  
  <pre><code>Module          IIS Web Core
  Notification    AuthenticateRequest
  Handler         StaticFile
  Error Code      0x80070542
  Requested URL   http://localhost:6365/Content/site.css
  Physical Path   C:\Users\Wally.Hartshorn\Visual Studio 2013\Projects\Experiment626\Experiment626\Content\site.css
  Logon Method   NTLM
  Logon User     SOMEDOMAIN\Wally.Hartshorn
  Request Tracing Directory   \\something.domain.com\SPIUsers1\Wally.Hartshorn\IISExpress\TraceLogFiles\EXPERIMENT626
  </code></pre>
  
  <p>I still have been unable to figure out how to view the actual exception that is thrown to trigger the status code 500.</p>
  
  <h1>UPDATE</h1>
  
  <p>Researching that error code, I found that it apparently means <strong>"Either a required impersonation level was not provided, or the provided impersonation level is invalid."</strong> I'm guessing that there is something about the way Firefox handles authentication that is different than the way Internet Explorer and Google Chrome, but I've no idea yet how to fix that.</p>
  
  <h1>UPDATE</h1>
  
  <p>As an experiment, I created a brand new ASP.NET MVC project in Visual Studio 2013, selecting Windows Authentication. Then, without making <strong>ANY</strong> changes to this brand new solution, I hit Ctrl-F5 to build it and open the default Home page in Firefox. I get the exact same error in the untouched project -- HTTP Server Error 500.0, with an error code of <code>0x80070542</code>, indicating "Either a required impersonation level was not provided, or the provided impersonation level is invalid."</p>
  
  <p>So apparently it has nothing to do with my code, but instead is a basic problem with how my Visual Studio 2013, IIS Express, and/or Windows 7 are configured.</p>
  
  <p>I'm stumped.</p>