I want to get the current method name of my ASP.NET Core
controller
I have tried getting the method name through reflection
[HttpGet]
public async Task<IActionResult> CreateProcess(int catId)
{
string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
but this gives me a value of MoveNext
and not CreateProcess
Take note I don't want to use the ViewContext
string methodName = ActionContext.RouteData.Values["action"].ToString();
as I lowercase my urls via the startup settings.The above will get me createprocess
instead of CreateProcess
I preferably want an easy one liner as not a multiline extension method.
Aucun commentaire:
Enregistrer un commentaire