运行一个从网上download的一个MVC项目,运行的时候无法显示样式,js也报错。
检查路径也没有问题,后来在配置中把其中的一段配置去掉
<staticContent>
<!-- remove first in case they are defined in IIS already, which would cause a runtime error -->
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
结果就可以正常显示,然后发现应该要加上<remove fileExtension=".json"/>,在配置节中出现了重复的.json节点,导致配置异常,系统无法正常运行。
只是IIS Express没有把错误抛出来。
后来经过尝试,把异常抛出来的步骤如下:
1.增加下面一段module,增加其他module也可以
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI .Web" />
</httpModules>
---->
<system.web>
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.5"/>
<httpRuntime targetFramework="4.5"/>
<authorization>
<allow users="*"/>
</authorization>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI .Web" />
</httpModules>
</system.web>
<system.webServer>
2.添加配置
<validation validateIntegratedModeConfiguration="true"/>
--->
<system.webServer>
<validation validateIntegratedModeConfiguration="true"/>
<staticContent>
<!-- remove first in case they are defined in IIS already, which would cause a runtime error -->
<remove fileExtension=".woff"/>
<remove fileExtension=".woff2"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff"/>
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2"/>
<mimeMap fileExtension=".json" mimeType="application/json"/>
</staticContent>
</system.webServer>
运行之后: