在本地iis上提供.net核心和角度5应用程序

问题描述 投票:0回答:1

我有以下设置:

  • 一个.net核心web api 2.1.x应用程序
  • 单独项目中的角度应用程序

我想在一个iis站点中托管它们,以便它们是这样的:

localhost\Site\ < --- angular app
localhost\Site\Api\ < --- web api app

我试图从虚拟文件夹运行.net核心web api项目,但没有运气。获得404次执行

如果我直接托管Web api项目(将应用程序路径绑定到\ Api文件夹),web api将起作用。但是那个应用程序还需要提供静态文件。由于某些原因,即使我启用它也不会做什么:

ConfigureServices

    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
1个回答
1
投票

管理让它工作,

万一有人来这个,这对我有用:

1.)使站点应用程序池与.net核心一起使用:

enter image description here

2.)在调用它的网站下创建一个应用程序将角度应用程序部署到该文件夹​​(不要忘记使用base-href构建角度应用程序来考虑该文件夹)将web.config更改为(看看标题。去掉 ):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <remove name="aspNetCore" />
      </handlers>
    </system.webServer>
  </location>
</configuration>

3.)在网站下创建另一个应用程序,例如backend

将.net核心web api应用程序部署到此文件夹中。

将qazxsw poi更改为(重要的是删除注释掉的标题部分):

web.config

希望它可以帮助某人

© www.soinside.com 2019 - 2024. All rights reserved.