• 本地Debug Asp.net MVC 无法加载css与js


    运行一个从网上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>

    运行之后:

     

  • 相关阅读:
    PHP数据类型
    Windows定时备份Mysql数据库
    Linux定时删除n天前日志
    使用file_get_contents() 发送GET、POST请求
    使用Git工具批量拉取代码
    Git常用命令
    点击开关按钮,通过改变类名切换按钮
    两个行内元素的间隙问题
    vue和angular双向数据绑定原理
    原生js实现 双向数据绑定
  • 原文地址:https://www.cnblogs.com/wanglg/p/8759070.html
Copyright © 2020-2023  润新知