繁体   English   中英

index.html没有在Angular2中部署

[英]index.html is not getting deployed in Angular2

我创建了一个以Angular2为前端的ASP.Net Core项目。

我已经将index.html文件放置在UI Project的主文件夹中,并且当我编译和发布项目时,它并没有部署到publish文件夹中。 以下是我在Startup.cs使用的代码

app.Use(async (context, next) => {
            await next();

            if (context.Response.StatusCode == 404 &&
                !Path.HasExtension(context.Request.Path.Value) &&
                !context.Request.Path.Value.StartsWith("/api"))
            {
                context.Request.Path = "/index.html";

                await next();
            }
        });

当我尝试直接从IIS访问文件时,它说找不到。

应用程序URL是http://localhost:81/

bs-config.json的内容如下

{
"server": {
"baseDir": "./dist",
"routes": {
   "/node_modules": "node_modules"
  }
 }
}

但是项目中没有./dist文件夹。

这是index.html文件的内容

    <!DOCTYPE html>
<html>
<head>
    <title>Node Junction</title>
    <base href="http://localhost:81">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="src/styles.css">

    <!-- Polyfill(s) for older browsers -->
    <script src="node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/zone.js/dist/zone.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>


    <script src="src/systemjs.config.js"></script>
    <script>
        System.import('main.js').catch(function (err) { console.error(err); });
    </script>
</head>

  <body>
    <my-app>Loading AppComponent content here ...</my-app>
  </body>
</html>

有什么线索吗?

您是否在索引文件中定义了启动指令?

将index.html放在wwwroot文件夹中。 那是应该从中提供静态文件的文件夹。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM