简体   繁体   English

ASP.NET Core 无法进入端点方法?

[英]ASP.NET Core can't step into endpoint method?

I have an API controller with a method like so:我有一个 API 控制器,其方法如下:

    [HttpGet]
    [Route("~/api/groups/{groupId}/feeds/{feedItemId}/flag")]
    [FeedItemAccess(AccessLevelTypes.GroupMember, "groupId")]
    public async Task<IActionResult> FlagFeedItem([FromRoute] int groupId, [FromRoute] long feedItemId)
    {
        try
        {
            await _feedManagementService.FlagMessage(groupId, feedItemId);
            return Ok();
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "FlagFeedItem(int)");
            return new OopsResult(ex);
        }
    }

I put breakpoints on the await line and on the _logger line.我在await行和_logger行上放置了断点。 I then use my REST client to hit the specified endpoint ( http://myhost/api/groups/1/feeds/1/flag ) in debug mode.然后我使用我的 REST 客户端在调试模式下访问指定的端点 ( http://myhost/api/groups/1/feeds/1/flag )。

I immediately get back a blank 200 response... but the await method is never hit, nor is the service underneath, and I never reach the breakpoint(s).我立即得到一个空白的 200 响应......但是 await 方法从未被命中,下面的服务也没有被命中,而且我从未到达断点。 I'm scratching my head on this.我正在挠头。 I would think this was a thread deadlocking issue but for the fact that it actually returns a 200 status code.我认为这是一个线程死锁问题,但事实上它实际上返回了 200 状态代码。

What could be the problem here?这里可能有什么问题? The routing appears to be correct, I can intercept on the controller's constructor, all looks fine... but when it gets here, the system just decides it doesn't actually need to do anything.路由似乎是正确的,我可以拦截控制器的构造函数,一切看起来都很好……但是当它到达这里时,系统只是决定它实际上不需要做任何事情。

BTW, the FeedItemAccess filter just checks the user's tenancy rights to connect to the endpoint;顺便说一句, FeedItemAccess过滤器只检查用户的租赁权限以连接到端点; it also appears to be working fine (I can intercept on that too and it's leaving the filter under success conditions).它似乎也工作正常(我也可以拦截它并且它在成功条件下离开过滤器)。

As @mjwills suggested, I should have been a bit more careful in dismissing what could or could not cause this behavior.正如@mjwills 所建议的那样,我应该更加小心地排除可能或不可能导致这种行为的原因。 I had thought I understood how the action filter was supposed to behave, and since it seemed to be doing what I wanted, I knew it wasn't the problem... but it actually was.我以为我了解动作过滤器应该如何工作,而且由于它似乎在做我想要的,我知道这不是问题......但它实际上是。

Removing all possible culprits and methodically adding them back in... sometimes it's the only way to find the problem.删除所有可能的罪魁祸首并有条不紊地将它们重新添加进来……有时这是找到问题的唯一方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM