直接给出代码,供参考。其中ApiGroups里面的keys就是controller的名字
private void LoadAssemblies() { var configuration = new HttpConfiguration(new HttpRouteCollection()); IAssembliesResolver assembliesResolver = new AnotherAssemblyResolver(); configuration.Services.Replace(typeof(IAssembliesResolver), assembliesResolver); configuration.MapHttpAttributeRoutes(); configuration.EnsureInitialized(); var apiExplorer = new ApiExplorer(configuration); var descriptions = apiExplorer.ApiDescriptions; ApiGroups = descriptions.Any() ? descriptions .GroupBy(d => d.ActionDescriptor.ControllerDescriptor.ControllerName) .ToDictionary(para => para.Key, para => para.ToList()) : new Dictionary<string, List<ApiDescription>>(); }