[CheckAccessMethod(RouteData.Values["action"].ToString())]
[HttpGet]
public IActionResult Get(){...}
class CheckAccessMethodAttribute : Attribute
{
string MethodName { get; set; }
public CheckAccessMethodAttribute(string methodName)
{
MethodName = methodName;
}
}
I can’t get the current request route. I want to create method access logic for users
One option would be to use the ActionFilterAttribute, then you'd have access to the ResultExecutingContext which has the route data you need. More information here