[ASP.NET Core通过Postman调用API

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

所以我在本地计算机上安装了这个ASP.NET Core,我已经安装了必备软件,并且在本地运行该应用程序之后,从Web浏览器得到的响应是正确的,找不到它。

[好,我正尝试通过邮递员调用此API,尽管已经检查了路由,但我无法确定为什么我无法访问它。

下面是示例模板

[HttpGet]
    [Route("Details")]
    public async Task<IActionResult> GetDetails(string value = null)
    {
        var response = new ListModelResponse<SomeModel>() as IListModelResponse<SomeModel>;

        try
        {
            response.Model = await GetDetailsRepository
                    .GetDetailsSS(value)
                    .Select(item => item.ToViewModel())      
                    .OrderBy(item => item.Name)
                    .ToListAsync();
        }
        catch (Exception ex)
        {
            response.DidError = true;
            response.ErrorMessage = ex.Message;
        }

        return response.ToHttpResponse();
    }

并且在Visual Studio的应用程序见解中,我可以看到它正在调用API,但似乎无法通过。Check this insights snippet

[其他API的运行正常,似乎我错过了我现在不知道的东西。

对于路由,我有这个。

[Route("api/[controller]")]

我还检查了令牌,并且在解析它时,我正在获取访问此API所需的信息。

感谢小伙子!

c# .net-core routing asp.net-core-webapi
1个回答
0
投票

似乎在请求URL中似乎没有控制器的名称。

api / [controller] / Details?value = CAT ...

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