简体   繁体   中英

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

I have an API controller with a method like so:

    [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. I then use my REST client to hit the specified endpoint ( http://myhost/api/groups/1/feeds/1/flag ) in debug mode.

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). 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.

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; 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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