C# 未在Angular2中部署index.html
我创建了一个以Angular2为前端的ASP.Net核心项目 我已将index.html文件放在UI项目的主文件夹中,当我编译并发布项目时,它不会部署到发布文件夹中。下面是我在C# 未在Angular2中部署index.html,c#,angular,iis,asp.net-core,C#,Angular,Iis,Asp.net Core,我创建了一个以Angular2为前端的ASP.Net核心项目 我已将index.html文件放在UI项目的主文件夹中,当我编译并发布项目时,它不会部署到发布文件夹中。下面是我在Startup.cs app.Use(async (context, next) => { await next(); if (context.Response.StatusCode == 404 && !Path.Ha
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>
节点连接
System.import('main.js').catch(函数(err){console.error(err);});
正在此处加载AppComponent内容。。。
有什么线索吗?是否在索引文件中定义了starting指令?将index.html放在wwwroot文件夹中。这是应该提供静态文件的文件夹。它是否在
wwwroot
文件夹中?否。它不在wwwroot文件夹中。在依赖项的npm部分,我得到了lite server(2.3.0)的黄色标记。这就是原因吗?修改了问题以包含index.htmlh是否手动将项目移动到UI项目?因为这可能是因为当你发布项目时,你已经将它从没有发布的原始源中移走了。我也准备好自动发布它。但是我需要WebAPI作为源代码,ASP.NET内核和Angular 2作为前端。我可能还需要检查已发布文件夹中的dll,看看它是否实际得到部署