刷新时在同一网站404上的IIS上部署Angular 4前端,.Net Web Api后端

问题描述 投票:0回答:1

我有一个由Angular 4前端客户端代码组成的Web应用程序,该代码调用用ASP.NET WebAPi编写的后端服务部分。我已经在同一网站上的IIS v10上部署了Web应用程序,但是在刷新时我未找到404异常。

因此,现在我在IIS中有一个网站,带有两个名为wwwroot的子目录,其中包含Angular生产代码和一个WebApi发布代码的bin文件夹。除非我按浏览器的“刷新”按钮(在此我接受“ 404异常”),否则该网站将正常运行。我在Internet上找到了许多解决方案,但没有人能解决。我尝试安装IIS的urlrewrite组件,并将此重写规则添加到位于根文件夹中的Web.config文件中:

<rewrite>
      <rules>
        <rule name="AngularJS Routes" stopProcessing="true">
          <match url=".*" />
          <conditions logicalGrouping="MatchAll">
            <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
            <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
            <add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
          </conditions>
          <action type="Rewrite" url="/" />
        </rule>
      </rules>
    </rewrite>

但是我得到了这个错误:localhost /:1资源解释为样式表,但以MIME类型text / html传输:“ http://localhost:8084/styles.a41bc47d7e564e63171c.bundle.css”。inline.f6f68ecaf0de3791ceeb.bundle.js:1未捕获的语法错误:意外令牌'

angular iis asp.net-web-api angular-ui-router iis-express
1个回答
0
投票
Uncaught SyntaxError: Unexpected token '<'

上述错误发生在它们不处理所请求的CSS和JS文件且服务器返回状态代码200且没有错误的情况下。但是返回的文件包含HTML文本错误

所以在上面,当您在网络标签中检查镶边中的响应时,您会发现

<!DOCTYPE HTML PUBLIC ...>
   <html>
     ...
 Some html error in side this 
</body></html>

我们已通过禁用IPv6检查策略解决了此问题。

© www.soinside.com 2019 - 2024. All rights reserved.