我有一个角度为8的netcore 3.1 Web应用程序,在我的本地环境下工作正常。但是将api部署到服务器上的IIS时似乎不起作用

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

1我有一个.netcore Web应用程序和一个有角度的8前端。 api和前端都可以在本地计算机上正常通信。但是当我在Windows服务器上部署到IIS时,api无法正常工作。我从服务的api请求中得到404。

我正在使用以下代码来设置api调用的基本网址

constructor(private http: HttpClient) {
        this.serviceBaseUrl = this.getServiceBaseApiUrl();//environment.serviceBaseUrl;
    }

    ngOnInit() { }

    getServiceBaseApiUrl(): string {
        if (environment.webApiEndPoint != 'dev') {
                //prod
                let paths: string[] = location.pathname.split('/').splice(1, 1);
                let basePath: string = (paths && paths[0]) || 'supplier'//Default:supplier

                this.hostName = basePath;
                this.serviceBaseUrl = this.hostName;//+ "/SupplierScreen";
                return this.serviceBaseUrl;
        }
        else {
            this.serviceBaseUrl = "https://localhost:44381";
            return this.serviceBaseUrl;
        }

    }
asp.net-core iis angular8 web-deployment asp.net-core-3.1
1个回答
0
投票

响应服务器返回404.0,因此仅表示未找到请求。首先,请确保已安装asp.net核心Web托管捆绑包。否则,静态文件处理程序将接管请求,并仅返回404以获取无扩展名的URL。其次,请确保URL正确并且您已经注册了处理程序。

 <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>

您是否在同一站点上托管了api和angular应用程序?因为看起来他们正在共享端口。

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