I want to get the current method name of my ASP.NET Core controller
I tried to get the method name through reflection:
[HttpGet] public async Task<IActionResult> CreateProcess(int catId) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
but it gives me the value of MoveNext , not CreateProcess
Please note: I do not want to use ViewContext
string methodName = ActionContext.RouteData.Values["action"].ToString();
as I am building my urls using startup settings. The above text will get CreateProcess instead of CreateProcess
I prefer a simple single-line rather than multi-line extension method.
source share