【问题标题】:angular2 does not load page on server, same thing is working on local machineangular2 不在服务器上加载页面,同样的事情在本地机器上工作
【发布时间】:2016-12-05 21:23:47
【问题描述】:

This is my project structure. I have index.html outside app folder. 当我在本地运行我的应用程序时,它可以正常工作。 Angular2 路由和页面渲染在本地机器上正常工作。

但是当我在服务器上托管这个应用程序时。页面路由不起作用。

我在我的 web .config 中包含以下代码来重写 URL,然后我可以将 index.html 页面称为默认页面。

`

<system.webServer>
<rewrite>
<rules>
<rule name="Angular2" 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>

`

但尚未渲染 angular2 页面。

我还在根域中发布了我的应用程序。并在 index.html 页面中也包含
&lt;base href="/"&gt;

请建议我该怎么做?

【问题讨论】:

  • 错误是什么?你去那里看到什么?
  • 用的是什么transpile呢?这是打字稿吗? dist 文件夹在哪里?
  • @xe4me 我正在使用打字稿来转换它。在服务器上我没有看到任何错误。仍然没有加载由角度 2 路由的我的内页。

标签: html .htaccess angular iis angular2-routing


【解决方案1】:

我终于找到了我的解决方案。我的内部网络(防火墙)阻止了我的 Angular 2 应用程序加载动态页面。在网络专家的帮助下,我解决了这个问题。

除了 URL 重写和基本路径之外,仍然需要在服务器上加载 Angular 应用程序。

谢谢。

【讨论】:

  • “在网络人员的帮助下我解决了这个问题”是什么意思?
  • @Jibeee - 在网络支持团队的帮助下,我从没有防火墙的另一台服务器请求了我的网站 URL,然后我们知道是我们服务器中的防火墙阻止了我的网站加载页面。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多