c# 扩展

public static string UrlName(this Type controller)
{
  var name = controller.Name;
  return name.EndsWith("Controller") ? name.Substring(0, name.Length - 10) : name;
}

  Then you can use:

Url.Action(nameof(ActionName), typeof(HomeController).UrlName())

  

猜你喜欢

转载自www.cnblogs.com/fireicesion/p/10753023.html