根据条件在方法上添加特性标签

如:在debug模式下方法不做权限检查

#if DEBUG
[AllowAnonymous]
#endif

[Authorize]
[HttpGet("GetData")]
#if DEBUG
[AllowAnonymous]
#endif
public string GetData()
{
    return _testService.GetDateTimeFormate();
}

 

posted @ 2024-11-25 16:31  流年sugar  阅读(11)  评论(0)    收藏  举报