title: 500 Internal Server Error requesting any resource files (css, js, images) in an .Net MVC 3 site
body: <p>UPDATE: Things I tried - see answer below for solution</p>
  
  <ol>
  <li>I installed a fresh MVC3 site and it served up the resources properly.  That eliminated the machine.config settings as a problem.</li>
  <li>I then when section by section in the web.config to see if any particular changes in web.config caused the problem.  When the configs were identical, the fresh site still worked and the old site was still broken.</li>
  <li>I uninstalled IIS, reinstalled IIS, and then installed apps again in an attempt to clear any settings that were lingering around.  Still borked.</li>
  <li>I then used publish (instead of msi deploy) to new directory.  I used the iis option to "Create Application" on new directory of exact same code that is broken.  Things worked perfectly.</li>
  <li>I assumed file permissions, so I deleted offending directory and renamed new working version to old directory name. Site was still borked.  This made me assume that some iis setting that is not in the machine.config or web.config is to blame.</li>
  <li>I used IIS 6 Metabase explorer (yes I used it on IIS 8 site) and saw quite a few entries that were not in the working site.  After deleting one by one, I found it was the "scriptMaps" entry that was being added during our MSI install causing a problem.  This was added to automatically add wildcard mappings during install.  It works on IIS6, but apparently not on IIS8.</li>
  </ol>
  
  <p>We have an webforms and MVC3 application that look like one application. This is deployed in many environments (2003, 2008, Win 7) and works properly.  I have just set these applications up on a new Windows Server 2012 machine and everything works except getting resource files for the MVC site.  The browser gets a </p>
  
  <pre><code>500 Internal Server Error
  Server Application Unavailable
  
  The web application you are attempting to access on this web server is currently unavailable.  Please hit the "Refresh" button in your web browser to retry your request.
  
  Administrator Note: An error message detailing the cause of this specific request failure can be found in the application event log of the web server. Please review this log entry to discover what caused this error to occur. 
  </code></pre>
  
  <p>The resources are referenced in the _layout.cshtml</p>
  
  <pre><code>&lt;head&gt;
      &lt;meta http-equiv='X-UA-Compatible' content='IE=EmulateIE8' /&gt;
      &lt;title&gt;@this.Title&lt;/title&gt;
      &lt;script type="text/javascript" src="@Url.Content("~/Scripts/2012.2.607/jquery-1.7.1.min.js")"&gt;&lt;/script&gt;    
      &lt;script type="text/javascript" src="/Sentri7/scripts/jquery-p1s.banner.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="/Sentri7/scripts/jquery-p1s.patientsearch.js"&gt;&lt;/script&gt;
      &lt;link type="text/css" rel="stylesheet" href="/sentri7/content/jquery-p1s.patientsearch.css"&gt;&lt;/link&gt;
      &lt;link type="text/css" rel="stylesheet" href="/sentri7/content/jquery-p1s.banner.css" /&gt;
      &lt;link type="text/css" rel="stylesheet" href="/quantifi/resources/application/css/jqueryui/jquery-ui-1.7.2.custom.css" /&gt;
      &lt;link type="text/css" rel="stylesheet" href="/quantifi/resources/application/css/styles.css" /&gt;
      @(RenderSection("PageHead", required: false))
  &lt;/head&gt;
  </code></pre>
  
  <p>as well as using the telerik scriptmanager:</p>
  
  <pre><code>@{
      Title = "Reportable Conditions";
      SelectedSubTab = SubTabIndex.Reportables;
      Html.Telerik().ScriptRegistrar().DefaultGroup(dg =&gt; dg
          .Add("~/Scripts/ReportableConditions/List.js")
          .Add("~/Scripts/ClientObjects/GridSettings.js"))
          .OnDocumentReady("bootStrapUI()");
  }
  </code></pre>
  
  <p>If I try to navigate directly to the javascript file, I get the same error:</p>
  
  <pre><code>http://[server]/S7D/Scripts/2012.2.607/jquery-1.7.1.min.js
  </code></pre>
  
  <p>Some weird stuff:</p>
  
  <ol>
  <li><p>If I IISReset and hit the js file, it will work the first request only.</p></li>
  <li><p>Any js, css, or image requested from another (webforms) site (same app pool) on the server works fine.</p></li>
  <li><p>There is nothing in the event log related to this 500 error.</p></li>
  </ol>
  
  <p>I have tried adding permissions full permissions to the user that the app pool is running.  I have also added file permissions to the [Machine]\IUSR.</p>
  
  <p>Here is my web.config</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;sectionGroup name="telerik"&gt;
        &lt;section name="webAssets" type="Telerik.Web.Mvc.Configuration.WebAssetConfigurationSection, Telerik.Web.Mvc" requirePermission="false" /&gt;
      &lt;/sectionGroup&gt;
      &lt;sectionGroup name="spring"&gt;
        &lt;section name="typeAliases" type="Spring.Context.Support.TypeAliasesSectionHandler, Spring.Core" /&gt;
        &lt;section name="context" type="Spring.Context.Support.WebContextHandler, Spring.Web" /&gt;
        &lt;section name="objects" type="Spring.Context.Support.DefaultSectionHandler, Spring.Core" /&gt;
      &lt;/sectionGroup&gt;
      &lt;sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"&gt;
        &lt;section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /&gt;
        &lt;section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /&gt;
      &lt;/sectionGroup&gt;
    &lt;/configSections&gt;
    &lt;spring&gt;
      &lt;context&gt;
        &lt;!-- Load web.config definition ** This resource reference is essential to define objects in the web.configs --&gt;
        &lt;resource uri="config://spring/objects" /&gt;
        &lt;resource uri="assembly://CAS2/CAS2.CASLibDAO/_SpringObjects.xml" /&gt;
        &lt;resource uri="file://~/App_Data/MvcApplicationContext.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Core/P1S.S7D.Core.ApplicationContext/ApplicationContext-Common.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Core/P1S.S7D.Core.ApplicationContext/ApplicationContext-DAO.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Core/P1S.S7D.Core.ApplicationContext/ApplicationContext.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Core/P1S.S7D.Core.ApplicationContext/Services.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Common/P1S.S7D.Common.ApplicationContext/ApplicationContext-AuthModule.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Common/P1S.S7D.Common.ApplicationContext/ApplicationContext-Web-Common.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Core/P1S.S7D.Core.ApplicationContext.WCF/ApplicationContext.xml" /&gt;
        &lt;resource uri="assembly://P1S.S7D.Core/P1S.S7D.Core.ApplicationContext/ApplicationContext-Circular-Reference-IPReporting.xml" /&gt;
      &lt;/context&gt;
      &lt;objects xmlns="http://www.springframework.net"&gt;
        &lt;!--cached objects--&gt;
      &lt;/objects&gt;
    &lt;/spring&gt;
    &lt;system.web.webPages.razor&gt;
      &lt;host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
      &lt;pages pageBaseType="P1S.S7D.Web.Mvc.WebViewPage"&gt;
        &lt;namespaces&gt;
          &lt;add namespace="P1S.S7D.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Helpers" /&gt;
          &lt;add namespace="System.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
          &lt;add namespace="System.Web.Mvc.Html" /&gt;
          &lt;add namespace="System.Web.Routing" /&gt;
          &lt;add namespace="System.Web.WebPages" /&gt;
          &lt;add namespace="Telerik.Web.Mvc.UI" /&gt;
        &lt;/namespaces&gt;
      &lt;/pages&gt;
    &lt;/system.web.webPages.razor&gt;
  
  
  
    &lt;appSettings&gt;
      &lt;add key="Spring.Data.NHibernate.Support.OpenSessionInViewModule.SessionFactoryObjectName" value="NHibernateSessionFactory" /&gt;
      &lt;add key="Spring.Data.NHibernate.Support.OpenSessionInViewModule.EntityInterceptorObjectName" value="MultiTenantInterceptor" /&gt;
      &lt;add key="webpages:Version" value="1.0.0.0" /&gt;
      &lt;add key="ClientValidationEnabled" value="true" /&gt;
      &lt;add key="UnobtrusiveJavaScriptEnabled" value="true" /&gt;
    &lt;/appSettings&gt;
    &lt;system.web&gt;
      &lt;sessionState allowCustomSqlDatabase="true" mode="SQLServer" sqlConnectionString="Server=dev-ct-nhsn.dev.rph.int;Database=aspstate;User ID=UID;Password=*****; Application Name=S7DSharedSession" /&gt;
       &lt;compilation debug="true" targetFramework="4.0"&gt;
        &lt;assemblies&gt;
          &lt;add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
          &lt;add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /&gt;
        &lt;/assemblies&gt;
      &lt;/compilation&gt;
      &lt;authentication mode="Forms"&gt;
        &lt;forms loginUrl="~/Account/LogOn" timeout="2880" /&gt;
      &lt;/authentication&gt;
      &lt;membership&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/membership&gt;
      &lt;profile&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
          &lt;add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/profile&gt;
      &lt;roleManager enabled="false"&gt;
        &lt;providers&gt;
          &lt;clear /&gt;
  
          &lt;add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /&gt;
          &lt;add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /&gt;
        &lt;/providers&gt;
      &lt;/roleManager&gt;
      &lt;pages pageBaseType="P1S.S7D.Web.Mvc.WebViewPage"&gt;
        &lt;namespaces&gt;
          &lt;add namespace="P1S.S7D.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Helpers" /&gt;
          &lt;add namespace="System.Web.Mvc" /&gt;
          &lt;add namespace="System.Web.Mvc.Ajax" /&gt;
          &lt;add namespace="System.Web.Mvc.Html" /&gt;
          &lt;add namespace="System.Web.Routing" /&gt;
          &lt;add namespace="System.Web.WebPages" /&gt;
          &lt;add namespace="Telerik.Web.Mvc.UI" /&gt;
        &lt;/namespaces&gt;
        &lt;controls&gt;
          &lt;add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /&gt;
        &lt;/controls&gt;
      &lt;/pages&gt;
      &lt;httpHandlers&gt;
        &lt;add verb="GET,HEAD" path="asset.axd" validate="false" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" /&gt;
      &lt;/httpHandlers&gt;
      &lt;httpModules&gt;
        &lt;add name="AuthenticationModule" type="Web.Handlers.AuthenticationModule,P1S.S7D.Web.Mvc" /&gt;
        &lt;add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" /&gt;
        &lt;add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate31" /&gt;
  
      &lt;/httpModules&gt;
          &lt;customErrors mode="Off" /&gt;
  
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
      &lt;validation validateIntegratedModeConfiguration="false" /&gt;
      &lt;modules runAllManagedModulesForAllRequests="true"&gt;
        &lt;add name="Spring" type="Spring.Context.Support.WebSupportModule, Spring.Web" /&gt;
        &lt;add name="AuthenticationModule" type="Web.Handlers.AuthenticationModule,P1S.S7D.Web.Mvc" /&gt;
        &lt;add name="OpenSessionInView" type="Spring.Data.NHibernate.Support.OpenSessionInViewModule, Spring.Data.NHibernate31" /&gt;
  
      &lt;/modules&gt;
      &lt;!--    --&gt;
      &lt;handlers&gt;
        &lt;remove name="asset" /&gt;
        &lt;add name="asset" preCondition="integratedMode" verb="GET,HEAD" path="asset.axd" type="Telerik.Web.Mvc.WebAssetHttpHandler, Telerik.Web.Mvc" /&gt;
      &lt;/handlers&gt;
  
    &lt;/system.webServer&gt;
    &lt;runtime&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /&gt;
          &lt;bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;
      &lt;assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"&gt;
        &lt;dependentAssembly&gt;
          &lt;assemblyIdentity name="NHibernate" culture="neutral" publicKeyToken="aa95f207798dfdb4" /&gt;
          &lt;bindingRedirect oldVersion="3.1.0.4000" newVersion="3.3.1.4000" /&gt;
        &lt;/dependentAssembly&gt;
      &lt;/assemblyBinding&gt;    
    &lt;/runtime&gt;
    &lt;telerik&gt;
      &lt;webAssets useTelerikContentDeliveryNetwork="false" /&gt;
    &lt;/telerik&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>All the resources, whether using Telerik or adding them with the script tag give the 500 error.  The controller and view show up correctly (without styles or javascript)</p>
  
  <p>EDIT:</p>
  
  <p>Register Routes:</p>
  
  <pre><code>    public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
          RouteTable.Routes.RouteExistingFiles = false;
          routes.MapRoute(
             "Default", // Route name
             "{controller}/{action}/{id}", // URL with parameters
             new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
         );
      }
  </code></pre>