How to get the current ASP.NET core controller method name inside the controller using Reflection or another accurate method

后端 未结 5 1562
深忆病人
深忆病人 2021-02-12 17:40

I want to get the current method name of my ASP.NET Core controller

I have tried getting the method name through reflection:

    [HttpGet]
         


        
5条回答
  •  抹茶落季
    2021-02-12 18:19

    You can get it by base.ControllerContext.ActionDescriptor.ActionName

    This works in .NET Core 1.0.

提交回复
热议问题