Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core 在同一域上托管Blazor WebAssembly和ASP.NET核心Web API_Asp.net Core_Nginx_Asp.net Web Api_Blazor - Fatal编程技术网

Asp.net core 在同一域上托管Blazor WebAssembly和ASP.NET核心Web API

Asp.net core 在同一域上托管Blazor WebAssembly和ASP.NET核心Web API,asp.net-core,nginx,asp.net-web-api,blazor,Asp.net Core,Nginx,Asp.net Web Api,Blazor,我有一个Blazor WebAssembly应用程序在linux服务器上运行,使用Nginx路由,如下所示: server { listen 80; listen [::]:80; root /var/www/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; server_name *.myurl.com; location

我有一个Blazor WebAssembly应用程序在linux服务器上运行,使用Nginx路由,如下所示:

server {
listen 80;
listen [::]:80;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

server_name *.myurl.com;

location / { 
    proxy_pass         http://localhost:5000;
    proxy_http_version 1.1;
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection keep-alive;
    proxy_set_header   Host $host;
    proxy_cache_bypass $http_upgrade;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto $scheme;
}
}
我希望能够在子域中的同一个域上承载ASP.NET核心Web API,并具有:

api.myurl.com/MyAPICall

或者在不同的路径上,如:

但我似乎无法让BlazorApp和Web API应用程序很好地配合使用。我已经尝试了几个小时来让这个工作,并尝试了大量的搜索和资源,但似乎找不到答案。我很高兴列出我尝试过的东西,只要问问,但是如果有人知道解决这个问题的简单方法,请帮助

编辑:出于测试目的,我还将添加默认BlazorWebAssembly和默认ASP.NET核心API项目(前者为Counter和FetchData应用程序,后者为WeatherForecast应用程序)。我也在使用.NET5.0和VisualStudio2019

编辑*:我知道了如何在同一个域上运行这两个函数,但api会响应。这是通过在控制器内的路由前面添加“api”来实现的,如下所示:

[Route("api/[controller]")]
不过,我还是想知道如何在子域(api.myurl.com/MyAPICall)中设置它