public static void PopulateDefaults(PageRouteModel model, string pageRoute, string routeTemplate) { model.RouteValues.Add("page", model.ViewEnginePath); if (AttributeRouteModel.IsOverridePattern(routeTemplate)) { throw new InvalidOperationException(string.Format( Resources.PageActionDescriptorProvider_RouteTemplateCannotBeOverrideable, model.RelativePath)); } var selectorModel = CreateSelectorModel(pageRoute, routeTemplate); model.Selectors.Add(selectorModel); var fileName = Path.GetFileName(model.RelativePath); if (string.Equals(IndexFileName, fileName, StringComparison.OrdinalIgnoreCase)) { // For pages ending in /Index.cshtml, we want to allow incoming routing, but // force outgoing routes to match to the path sans /Index. selectorModel.AttributeRouteModel.SuppressLinkGeneration = true; var index = pageRoute.LastIndexOf('/'); var parentDirectoryPath = index == -1 ? string.Empty : pageRoute.Substring(0, index); model.Selectors.Add(CreateSelectorModel(parentDirectoryPath, routeTemplate)); } }
private static void PopulateRouteModel(PageRouteModel model, string pageRoute, string routeTemplate) { model.RouteValues.Add("page", model.ViewEnginePath); var selectorModel = CreateSelectorModel(pageRoute, routeTemplate); model.Selectors.Add(selectorModel); string fileName = Path.GetFileName(model.RelativePath); if (AttributeRouteModel.IsOverridePattern(routeTemplate) || !string.Equals(IndexFileName, fileName, StringComparison.OrdinalIgnoreCase)) { return; } selectorModel.AttributeRouteModel.SuppressLinkGeneration = true; int length = pageRoute.LastIndexOf('/'); string prefix = length == -1 ? string.Empty : pageRoute.Substring(0, length); model.Selectors.Add(CreateSelectorModel(prefix, routeTemplate)); }
private static void PopulateRouteModel(PageRouteModel model, string pageRoute, string routeTemplate) { model.RouteValues.Add("page", model.ViewEnginePath); var selectorModel = CreateSelectorModel(pageRoute, routeTemplate); model.Selectors.Add(selectorModel); var fileName = Path.GetFileName(model.RelativePath); if (AttributeRouteModel.IsOverridePattern(routeTemplate) && string.Equals(IndexFileName, fileName, StringComparison.OrdinalIgnoreCase)) { // For pages without on override route, and ending in /Index.cshtml // I want ot allow incoming routing, but force outgoing routes to match to the path sans /Index. selectorModel.AttributeRouteModel.SuppressLinkGeneration = true; var index = pageRoute.LastIndexOf('/'); var parentDirectoryPath = index == -1 ? string.Empty : pageRoute.Substring(0, index); model.Selectors.Add(CreateSelectorModel(parentDirectoryPath, routeTemplate)); } }