【发布时间】:2018-07-09 09:15:14
【问题描述】:
我正在尝试在 IIS 上部署 Angular 应用程序。当我在 IIS 中执行 Sites -> RightClick -> Select Add Web Site as mywebapp 时,它会起作用。但是,如果我在 IIS 中执行 Default Web Site -> RightClick -> Select Add Application as mywebapp,则它不起作用。
第一种情况,应用的Url是http://localhost。
在第二种情况下,应用程序的 URL 是 http://localhost/mywebapp
在第二种情况下,它会在浏览器控制台中出现错误。
GET http://localhost/scripts.bundle.js 404(未找到)
所以错误理解为我的应用程序正在尝试访问http://localhost/scripts.bundle.js,但它不存在,它应该在第二种情况下访问http://localhost/mywebapp/scripts.bundle.js。
启动页Index.html的HTML。
<!doctype html>
<html lang="en" dir="ltr" style="height:100%">
<head>
<meta charset="utf-8">
<title>mywebapp</title>
<base href="/">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<meta name="author" content="">
<meta name="description" content="">
<link rel="shortcut icon" type="image/x-icon" href="assets/images/favicon.png">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.dataTables.net/1.10.15/css/jquery.dataTables.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body class="theme-red">
<app-root></app-root>
<script type="text/javascript" src="inline.bundle.js"></script><script type="text/javascript" src="polyfills.bundle.js"></script><script type="text/javascript" src="styles.bundle.js"></script><script type="text/javascript" src="scripts.bundle.js"></script><script type="text/javascript" src="vendor.bundle.js"></script><script type="text/javascript" src="main.bundle.js"></script></body>
</html>
部署应用的步骤:
- 在命令提示符下从 Angular 文件夹运行
ng build。 - 将 dist 文件夹文件复制到某个 abc 文件夹中。
- 将 abc 文件夹添加为虚拟目录。
【问题讨论】:
标签: angular iis aspnetboilerplate