/// <summary> /// Gets the area name. /// </summary> /// <param name="routeAreaAttribute">The <see cref="RouteAreaAttribute"/> for the controller.</param> /// <param name="controllerType">The type of the controller.</param> /// <returns>The name of the area.</returns> private static string GetAreaName(RouteAreaAttribute routeAreaAttribute, Type controllerType) { if (routeAreaAttribute == null) return null; // If given an area name, then use it. // Otherwise, use the last section of the namespace of the controller, as a convention. return routeAreaAttribute.AreaName ?? controllerType.GetConventionalAreaName(); }
private static string GetAreaUrl(RouteAreaAttribute routeAreaAttribute, string subdomain, Type controllerType) { if (routeAreaAttribute == null) { return null; } // If a subdomain is specified for the area either in the RouteAreaAttribute // or via configuration, then assume the area url is blank; eg: admin.badass.com. // However, our fearless coder can decide to explicitly specify an area url if desired; // eg: internal.badass.com/admin. if (subdomain.HasValue() && routeAreaAttribute.AreaUrl.HasNoValue()) { return null; } // If we're given an area url or an area name, then use it. // Otherwise, get the area name from the namespace of the controller, as a convention. var areaUrlOrName = routeAreaAttribute.AreaUrl ?? routeAreaAttribute.AreaName; return areaUrlOrName ?? controllerType.GetConventionalAreaName(); }