从IIS提供ember应用程序导致UnrecognizedURLError

时间:2015-10-09 15:50:37

标签: javascript iis ember.js ember-cli

我正在尝试从IIS提供一个ember应用程序。

我使用ember new my-app创建了一个新应用,然后运行ember build --environment production。这会按预期生成dist目录中的文件。

在IIS方面,我在服务器上添加了一个新网站,并从最后一步映射了dist文件夹。

现在,当我导航到localhost/index.html时,我会看到一个空白页。

我检查了页面的来源,并按预期正确提供了js文件。这意味着它是未正确检索的模板。在chrome检查器控制台中,有一个例外Uncaught: UnrecognizedURLError: /index.html。烬检查员说没有检测到Ember应用程序!'。

我已经尝试了here提到的解决方案,但没有一个对我有效。

是否有其他人遇到此问题/知道如何解决此问题?

1 个答案:

答案 0 :(得分:4)

默认情况下,Ember路由器使用location: history。这意味着,它假定/index.html是您的路线。但显然它没有定义,所以路由器抛出UnrecognizedURLError

您的问题有几种解决方案:

  1. 在您的ember应用程序的locationType: 'hash'中设置config/environment.js。这将迫使Ember路由器在url中使用#进行路由,在您的情况下,这将类似于localhost/index.html#your/route

  2. 配置IIS实例以将index.html作为默认文档处理。要执行此操作,请打开服务器配置并确保其具有密钥:

  3. enter image description here

    1. 更改ember build config以生成index.aspx而不是index.html。您可以阅读here