Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/266.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/2/.net/20.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
C# .net core api为每个请求返回clients index.html文件_C#_.net_Api_React Redux - Fatal编程技术网

C# .net core api为每个请求返回clients index.html文件

C# .net core api为每个请求返回clients index.html文件,c#,.net,api,react-redux,C#,.net,Api,React Redux,我使用dotnet new reactredux命令设置了一个reactredux/dotnetcore应用程序。我正在尝试测试我的api,但是每当我尝试获取一些东西时,我得到的唯一东西就是来自react客户端的index.html。即使对于端点,我也没有指定 我让我的应用程序在localhost 5000和5001上运行,对于这两个应用程序,我得到了相同的结果 我忘记设置一些设置了吗? 我用错地址了吗?哪里可以找到合适的。每当MVC后端没有匹配的请求路由时,ASP.NET Core SPA t

我使用
dotnet new reactredux
命令设置了一个reactredux/dotnetcore应用程序。我正在尝试测试我的api,但是每当我尝试获取一些东西时,我得到的唯一东西就是来自react客户端的index.html。即使对于端点,我也没有指定

我让我的应用程序在localhost 5000和5001上运行,对于这两个应用程序,我得到了相同的结果

我忘记设置一些设置了吗?

我用错地址了吗?哪里可以找到合适的。每当MVC后端没有匹配的请求路由时,ASP.NET Core SPA templates会将您重定向到SPA index.html静态页面。将此控制器添加到应用程序中,并查看是否可以从中获得响应。如果可行,请将更改与正在调用的其他控制器进行比较:

[Route("api/[controller]")]
public class TestController : ControllerBase
{
    [Route("[action]")]
    public IActionResult Test() => Content("Hello World!");
}