【问题标题】:.net core 5.0 angular 10 running on windows IIS server [closed]在 Windows IIS 服务器上运行的 .net core 5.0 angular 10 [关闭]
【发布时间】:2021-05-25 07:15:26
【问题描述】:

页面出现空白,但此错误使页面无法加载。如果有人找到可靠的解决方法。 .谢谢!

Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. /main-es2015.381030b3d21caf13619a.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. /polyfills-es2015.8005eab2c6721bac0373.js:1 Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec. scripts.dfe5da540b50ddf65e43.js:1 Uncaught SyntaxError: Unexpected token '<'

【问题讨论】:

    标签: .net angular asp.net-core


    【解决方案1】:

    当您在 IIS 中托管 Angular 或 React 基础应用程序时。您需要添加如下重写规则。

    <configuration>
    <system.webServer>
      <rewrite>
        <rules>
          <rule name="Redirect all requests" stopProcessing="true">
            <match url=".*" />
            <conditions logicalGrouping="MatchAll">
                <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            </conditions>
            <action type="Rewrite" url="public/index.html" />
            </rule>
        </rules>
      </rewrite>
    </system.webServer>
    </configuration>
    

    首先安装url rewrite module

    当你添加它时,它将为你的 JS 文件提供服务。

    【讨论】:

    • 是的,我尝试过,但对于 .net 核心似乎无法正常工作。感谢您的快速回复。我仍然遇到同样的错误。
    • 此行需要根据您的设置进行相应更改。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-01
    • 2020-05-28
    • 2021-05-12
    • 2019-10-07
    相关资源
    最近更新 更多