【问题标题】:IIS website host multiple Angular applicationsIIS 网站托管多个 Angular 应用程序
【发布时间】:2019-10-14 15:57:21
【问题描述】:

我想在单个 IIS 虚拟目录上托管多个独立的 Angular 应用程序

例如

  • mysite.com/admin

  • mysite.com/sales

  • mysite.com/inventory

如果我使用文件夹进行托管,那么指向内页的 URL 将不起作用

例如:

  • mysite.com/admin--- 工作

  • mysite.com/admin/home --- 不工作

【问题讨论】:

  • 是的,这是可行的。只需将每个应用程序部署到相应的文件夹即可。
  • 在iis中我是否需要将带有iis路由模块的路由配置添加到目标索引页面?

标签: asp.net angular iis web-hosting


【解决方案1】:

你只需要做以下事情:

在 index.file 中设置基本 href:

 <base href="/app3/">

另一个是设置脚本链接如下:

<script type="text/javascript" src="./runtime.js"></script>

你只需要添加 ./

所以你的整个代码看起来像:

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>AngularApp2</title>
  <base href="/app3/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="./favicon.ico">
</head>
<body>
<h2>app3</h2>
  <app-root></app-root>
<script type="text/javascript" src="./runtime.js"></script>
<script type="text/javascript" src="./es2015-polyfills.js" nomodule></script>
<script type="text/javascript" src="./polyfills.js"></script>
<script type="text/javascript" src="./styles.js"></script>
<script type="text/javascript" src="./vendor.js"></script>
<script type="text/javascript" src="./main.js"></script></body>
</html>

当您托管 Angular 应用程序 iis 时,不要忘记将 dist 文件夹设置为文件夹路径。

【讨论】:

  • 感谢 Jalpa,我已经尝试过了,但 URL 路由不起作用。例如,如果我点击 localhost/app3/home 将不起作用,但 localhost/app3/ 将起作用
  • 你能分享你的 URL 路由吗?对于 URL 重写路由规则问题,您可以运行 failed request tracing 并检查原因。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2020-07-26
  • 2018-01-15
  • 1970-01-01
  • 1970-01-01
  • 2022-01-08
  • 2019-03-21
  • 1970-01-01
相关资源
最近更新 更多