蔚蓝 AngularJS Index.html

Azure AngularJS Index.html

我的 AngularJS 应用程序需要将所有操作重定向到 index.html 进行处理,它在本地主机上运行良好,但在 Azure 中不起作用。 例如:

localhost:1234 -> localhost:1234/#/ 有效

myapp.com -> myapp.com/#/ 不起作用

myapp.com/index.html -> myapp.com/index.html#/ works

我补充了:

<system.webServer xdt:Transform="Replace">
<rewrite>
  <rules>
    <rule name="redirect all requests" stopProcessing="true">
      <match url="^(.*)$" ignoreCase="false" />
      <conditions logicalGrouping="MatchAll">
        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" pattern="" ignoreCase="false" />
      </conditions>
      <action type="Rewrite" url="index.html" appendQueryString="true" />
    </rule>
  </rules>
</rewrite>
</system.webServer>

奇怪的是,这有时会奏效。我终其一生都无法弄清楚为什么有时去 myapp.com -> myapp.com/#/ 有效而其他时候却无效。它似乎也打破了 myapp.com/index.html#/ 但只是有时。这没有进行任何部署更改。它只工作了大约一半的时间。

编辑

这是实际的错误消息:

Microsoft.Owin, Version=2.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

可能与应用程序启动有关。以下是一些故障排除思路。

重新启动您的应用程序。这确实会导致错误吗?

打开应用程序日志记录。 portal.azure.com > 浏览全部 > 站点名称 > 设置 > 诊断日志 > 应用程序日志记录 > 级别错误。如果您想要很多东西,请将级别设置为详细并打开 Web 服务器日志记录、详细的错误消息和失败的请求跟踪。

在服务控制管理器中查看诊断信息 mysite.scm.azurewebsites.net。选择调试控制台 > PowerShell。现在您可以在 home/LogFiles.

查看日志

根据您收到的错误,Owin 似乎是问题所在。检查您的网站 bin 以查看是否有任何 Owin 参考资料。从在线服务控制管理器,你可以试试这个:

cd site/wwwroot/bin
Get-ChildItem -filter *Owin*

如果那里有任何东西,那么它可能是您收到的特定错误的原因。