在本地iis上提供.net核心和angular 5应用

时间:2018-09-17 14:55:16

标签: angular iis asp.net-core asp.net-core-webapi

我有以下设置:

  • .net核心Web api 2.1.x应用程序
  • 单独项目中的Angular应用

我想将它们都托管在一个iis网站中,以使它们像这样:

d = {}
for l in rept:
    d.setdefault(l[0], []).append(l)
list(d.values())
# [[['Name', '=', 'John'], ['Name', '=', 'John']],
#  [['Weight', '=', '60'], ['Weight', '=', '60']]]

我尝试从虚拟文件夹运行.net核心Web api项目,但没有运气。获取404执行

如果我直接托管Web api项目(将应用程序路径绑定到\ Api文件夹),则Web api可以工作。但是随后该应用程序还需要提供静态文件巫婆,即使我启用了它,也不愿意出于某些原因这样做:

ConfigureServices

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

...

配置

    services.AddSpaStaticFiles(configuration =>
    {
        configuration.RootPath = "App";
    });

有人知道我在哪里可以找到一些有关此的说明吗?

2 个答案:

答案 0 :(得分:1)

设法使其正常工作,

万一有人出现,这对我有用:

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

enter image description here

2。)在名为app的网站下创建一个应用程序 将angular应用程序部署到该文件夹​​(别忘了使用base-href来构建angular应用程序以解决该文件夹) 将web.config更改为(看看headers.remove):

<?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应用程序部署到此文件夹中。

web.config更改为(重要的是删除注释掉的标题部分):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.webServer>
       <!-- <handlers> -->
         <!-- <remove name="aspnetcore" path="*" verb="*" modules="aspnetcoremodule" resourcetype="unspecified" />  -->
       <!-- </handlers>  -->
      <aspNetCore processPath="dotnet" arguments=".\core.rest.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
</configuration>

希望它对某人有帮助

答案 1 :(得分:0)

我也遇到类似的问题,发现.NET Core应用程序和Angular应用程序必须配置为IIS中同一网站下的单独应用程序。这可能是一个众所周知的事实,但我在任何地方都找不到它