【发布时间】:2019-02-21 13:00:45
【问题描述】:
我有以下设置:
- .net core web api 2.1.x 应用程序
- 单独项目中的 Angular 应用程序
我想将它们都托管在一个 iis 站点中,以便它们像这样:
localhost\Site\ < --- angular app
localhost\Site\Api\ < --- web api app
我尝试从虚拟文件夹运行 .net core web api 项目,但没有成功。获取 404 执行
如果我直接托管 Web api 项目(将应用程序路径绑定到 \Api 文件夹),则 Web api 可以工作。但是那个应用程序还需要提供静态文件女巫它由于某种原因即使我启用了也不想做:
配置服务
services.AddSpaStaticFiles(configuration =>
{
configuration.RootPath = "App";
});
...
配置
app.UseStaticFiles(new StaticFileOptions()
{
OnPrepareResponse = (context) =>
{
// Disable caching for all static files.
context.Context.Response.Headers["Cache-Control"] = Configuration["StaticFiles:Headers:Cache-Control"];
context.Context.Response.Headers["Pragma"] = Configuration["StaticFiles:Headers:Pragma"];
context.Context.Response.Headers["Expires"] = Configuration["StaticFiles:Headers:Expires"];
}
});
有人知道我在哪里可以找到有关此的说明吗?
【问题讨论】:
标签: angular iis asp.net-core asp.net-core-webapi