【问题标题】:Angular 5 deployment to IIS server , navigation routes from dist folder not workingAngular 5 部署到 IIS 服务器,来自 dist 文件夹的导航路线不起作用
【发布时间】:2018-07-05 08:15:12
【问题描述】:

据我了解,如果我构建并部署在“dist”文件夹中生成的代码,那么所有的打字稿和路由都准备好工作了吗?!

我在dist文件夹中部署了代码,主页就可以正常显示了

只要我点击一个链接,我就会得到一个 404(IIS 服务器)

路线示例

/criminal/?UserID...


{ path: 'criminal', component: CriminalComponent, pathMatch: 'full'},

【问题讨论】:

  • 在 .angular-cli.json 中,我将 outDir 设置为 wwwroot,因为这是 VS 和 IIS 通常要寻找的: --> "outDir": "wwwroot"
  • 考虑使用HashLocationStrategy
  • 确保在部署之前也执行“ng build --prod”。这将确保您的应用程序的核心正确组合在一起并且没有构建错误。

标签: angular iis angular-cli ng-build


【解决方案1】:

您应该遵循本教程:

https://blog.angularindepth.com/deploy-an-angular-application-to-iis-60a0897742e7

在高层次上:

  1. 安装 URL 重写
  2. 根据需要处理子文件夹和基本 URL
  3. 添加 web.config 文件以在您进行构建时部署

【讨论】:

    猜你喜欢
    • 2018-10-11
    • 1970-01-01
    • 2020-02-06
    • 2017-09-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-03
    相关资源
    最近更新 更多