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

后端 未结 5 1559
深忆病人
深忆病人 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:01

    Use the StackTrace class snd its GetFrames until you find the one you want.

提交回复
热议问题