public static IEndpointRouteBuilder UseCustomRoutes(this IEndpointRouteBuilder routes) { routes.AddBlogRoutesForSimpleContent(); routes.AddSimpleContentStaticResourceRoutes(); routes.AddCloudscribeFileManagerRoutes(); routes.MapControllerRoute( name: "errorhandler", pattern: "oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" } ); routes.MapControllerRoute( name: "sitemap", pattern: "sitemap", defaults: new { controller = "Page", action = "SiteMap" } ); IRouteBuilder route; routes.MapControllerRoute( name: "def", "{controller}/{action}", defaults: new { action = "Index" } ); //routes.AddDefaultPageRouteForSimpleContent(); return(routes); }
//not currently used public static IEndpointRouteBuilder UseCustomRoutes(this IEndpointRouteBuilder routes, bool useFolders) { if (useFolders) { routes.AddBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); } routes.AddBlogRoutesForSimpleContent(); routes.AddSimpleContentStaticResourceRoutes(); routes.AddCloudscribeFileManagerRoutes(); if (useFolders) { routes.MapControllerRoute( name: "foldererrorhandler", pattern: "{sitefolder}/oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" }, constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifoldersitemap", pattern: "{sitefolder}/api/sitemap" , defaults: new { controller = "FolderSiteMap", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "foldersitemap", pattern: "{sitefolder}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifoldermetaweblog", pattern: "{sitefolder}/api/metaweblog" , defaults: new { controller = "FolderMetaweblog", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifolderrss", pattern: "{sitefolder}/api/rss" , defaults: new { controller = "FolderRss", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "folderdefault", pattern: "{sitefolder}/{controller}/{action}/{id?}", defaults: null, constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.AddDefaultPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); } routes.MapControllerRoute( name: "errorhandler", pattern: "oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" } ); routes.MapControllerRoute( name: "sitemap", pattern: "sitemap" , defaults: new { controller = "Page", action = "SiteMap" } ); routes.MapControllerRoute( name: "def", pattern: "{controller}/{action}" , defaults: new { action = "Index" } ); routes.AddDefaultPageRouteForSimpleContent(); return(routes); }
/// <summary> /// this is the new 3.0 endpoint routing but it has bugs that break folder tenants and culture segment route constraints /// </summary> /// <param name="routes"></param> /// <param name="useFolders"></param> /// <param name="config"></param> /// <returns></returns> public static IEndpointRouteBuilder UseCustomRoutes( this IEndpointRouteBuilder routes, bool useFolders, IConfiguration config) { var useCustomRoutes = config.GetValue <bool>("DevOptions:UseCustomRoutes"); if (useFolders) { routes.AddCultureBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), new CultureSegmentRouteConstraint(true)); routes.AddBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); } routes.AddCultureBlogRoutesForSimpleContent(new CultureSegmentRouteConstraint()); routes.AddBlogRoutesForSimpleContent(); routes.AddSimpleContentStaticResourceRoutes(); //TODO filemanager culture routes? routes.AddCloudscribeFileManagerRoutes(); if (useFolders) { routes.MapControllerRoute( name: "foldererrorhandler", pattern: "{sitefolder}/oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" }, constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifoldersitemap-localized", pattern: "{sitefolder}/{culture}/api/sitemap" , defaults: new { controller = "FolderSiteMap", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "apifoldersitemap", pattern: "{sitefolder}/api/sitemap" , defaults: new { controller = "FolderSiteMap", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "folderserviceworker", pattern: "{sitefolder}/serviceworker" , defaults: new { controller = "Pwa", action = "ServiceWorker" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifoldermetaweblog-localized", pattern: "{sitefolder}/{culture}/api/metaweblog" , defaults: new { controller = "FolderMetaweblog", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "apifoldermetaweblog", pattern: "{sitefolder}/api/metaweblog" , defaults: new { controller = "FolderMetaweblog", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifolderrss-localized", pattern: "{sitefolder}/{culture}/api/rss" , defaults: new { controller = "FolderRss", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "apifolderrss", pattern: "{sitefolder}/api/rss" , defaults: new { controller = "FolderRss", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); if (useCustomRoutes) { routes.MapControllerRoute( name: "folderdefault", pattern: "{sitefolder}/{controller}/{action}/{id?}" , defaults: new { controller = "Home", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.AddCultureCustomPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), new CultureSegmentRouteConstraint(true), "docs"); routes.AddCustomPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), "docs"); } else { routes.MapControllerRoute( name: "foldersitemap-localized", pattern: "{sitefolder}/{culture}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "foldersitemap", pattern: "{sitefolder}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "folderdefault-localized", pattern: "{sitefolder}/{culture}/{controller}/{action}/{id?}", defaults: new { controller = "Home" }, constraints: new { sitefolder = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) }); routes.MapControllerRoute( name: "folderdefault", pattern: "{sitefolder}/{controller}/{action}/{id?}" , defaults: new { controller = "Home" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.AddCulturePageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), new CultureSegmentRouteConstraint(true)); routes.AddDefaultPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); //routes.AddBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(),""); } } if (useCustomRoutes) { routes.AddCultureCustomPageRouteForSimpleContent(new CultureSegmentRouteConstraint(), "docs"); routes.AddCustomPageRouteForSimpleContent("docs"); } routes.MapControllerRoute( name: "errorhandler", pattern: "oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" } ); routes.MapControllerRoute( name: "api-sitemap-culture", pattern: "{culture}/api/sitemap" , defaults: new { controller = "CultureSiteMap", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "api-rss-culture", pattern: "{culture}/api/rss" , defaults: new { controller = "CultureRss", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "api-metaweblog-culture", pattern: "{culture}/api/metaweblog" , defaults: new { controller = "CultureMetaweblog", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); //routes.AddPwaDefaultRoutes(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); routes.MapControllerRoute( name: "sitemap-localized", pattern: "sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "sitemap", pattern: "sitemap" , defaults: new { controller = "Page", action = "SiteMap" } ); var useHomeIndexAsDefault = config.GetValue <bool>("DevOptions:UseHomeIndexAsDefault"); if (useHomeIndexAsDefault) { routes.MapControllerRoute( name: "default-localized", pattern: "{culture}/{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index" }, constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "default", pattern: "{controller}/{action}" , defaults: new { controller = "Home", action = "Index" } ); } else { routes.MapControllerRoute( name: "default-localized", pattern: "{culture}/{controller}/{action}/{id?}", defaults: null, constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "default", pattern: "{controller}/{action}" //, defaults: new { controller = "Home", action = "Index" } ); } if (!useCustomRoutes) { routes.AddCulturePageRouteForSimpleContent(new CultureSegmentRouteConstraint()); routes.AddDefaultPageRouteForSimpleContent(); } //routes.AddBlogRoutesForSimpleContent(""); return(routes); }
public static IEndpointRouteBuilder UseCustomRoutes(this IEndpointRouteBuilder routes) #endif { #if (SimpleContentConfig != "z") #if (SimpleContentConfig != "c") #if (MultiTenantMode == 'FolderName') if (useFolders) { routes.AddCultureBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), new CultureSegmentRouteConstraint(true)); routes.AddBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); } #endif routes.AddCultureBlogRoutesForSimpleContent(new CultureSegmentRouteConstraint()); routes.AddBlogRoutesForSimpleContent(); #endif routes.AddSimpleContentStaticResourceRoutes(); #endif routes.AddCloudscribeFileManagerRoutes(); #if (MultiTenantMode == 'FolderName') if (useFolders) { routes.MapControllerRoute( name: "foldererrorhandler", pattern: "{sitefolder}/oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" }, constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifoldersitemap-localized", pattern: "{sitefolder}/{culture}/api/sitemap" , defaults: new { controller = "FolderSiteMap", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "apifoldersitemap", pattern: "{sitefolder}/api/sitemap" , defaults: new { controller = "FolderSiteMap", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); #if (ContactForm) routes.MapControllerRoute( name: "foldercontact-localized", pattern: "{sitefolder}/{culture}/contact", defaults: new { controller = "Contact", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "foldercontact", pattern: "{sitefolder}/contact", defaults: new { controller = "Contact", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); #endif #if (SimpleContentConfig == "a" || SimpleContentConfig == "b") routes.MapControllerRoute( name: "foldersitemap-localized", pattern: "{sitefolder}/{culture}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "foldersitemap", pattern: "{sitefolder}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifoldermetaweblog-localized", pattern: "{sitefolder}/{culture}/api/metaweblog" , defaults: new { controller = "FolderMetaweblog", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), culture = new CultureSegmentRouteConstraint(true) } ); routes.MapControllerRoute( name: "apifoldermetaweblog", pattern: "{sitefolder}/api/metaweblog" , defaults: new { controller = "FolderMetaweblog", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); routes.MapControllerRoute( name: "apifolderrss", pattern: "{sitefolder}/api/rss" , defaults: new { controller = "FolderRss", action = "Index" } , constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); #endif #if (SimpleContentConfig == "c") // you can easily add pages by uncommenting this and uncommenting the coresponding node in navigation.xml //routes.AddCustomPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), "NONROOTPAGESEGMENT"); #endif #if (SimpleContentConfig == "a" || SimpleContentConfig == "c") routes.MapControllerRoute( name: "folderdefault", pattern: "{sitefolder}/{controller}/{action}/{id?}", defaults: null, constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); #endif #if (SimpleContentConfig == "a") routes.AddCulturePageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), new CultureSegmentRouteConstraint(true)); routes.AddDefaultPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); #endif #if (SimpleContentConfig == "b") routes.AddCultureCustomPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), new CultureSegmentRouteConstraint(true), "NONROOTPAGESEGMENT"); routes.AddCustomPageRouteForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), "NONROOTPAGESEGMENT"); #endif #if (SimpleContentConfig == "z" || SimpleContentConfig == "b" || SimpleContentConfig == "d") routes.MapControllerRoute( name: "folderdefault", pattern: "{sitefolder}/{controller}/{action}/{id?}", defaults: new { action = "Index" }, constraints: new { name = new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint() } ); #endif #if (SimpleContentConfig == "c") //blog as default route routes.AddBlogRoutesForSimpleContent(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint(), ""); #endif } #endif routes.MapControllerRoute( name: "errorhandler", pattern: "oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" } ); #if (Forum) routes.AddForumRoutes(new cloudscribe.Core.Web.Components.SiteFolderRouteConstraint()); #endif #if (ContactForm) routes.MapControllerRoute( name: "contact", pattern: "contact", defaults: new { controller = "Contact", action = "Index" } ); #endif #if (SimpleContentConfig == "a" || SimpleContentConfig == "b") routes.MapControllerRoute( name: "api-sitemap-culture", pattern: "{culture}/api/sitemap" , defaults: new { controller = "CultureSiteMap", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "api-rss-culture", pattern: "{culture}/api/rss" , defaults: new { controller = "CultureRss", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "api-metaweblog-culture", pattern: "{culture}/api/metaweblog" , defaults: new { controller = "CultureMetaweblog", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "sitemap-localized", pattern: "{culture}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "sitemap", pattern: "sitemap" , defaults: new { controller = "Page", action = "SiteMap" } ); #endif #if (SimpleContentConfig == "c") // you can easily add pages by uncommenting this and uncommenting the coresponding node in navigation.xml //routes.AddCustomPageRouteForSimpleContent("NONROOTPAGESEGMENT"); #endif #if (SimpleContentConfig == "a" || SimpleContentConfig == "c") routes.MapControllerRoute( name: "default-localized", pattern: "{culture}/{controller}/{action}/{id?}", defaults: new { action = "Index" }, constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "def", pattern: "{controller}/{action}" , defaults: new { action = "Index" } ); #endif #if (SimpleContentConfig == "a") routes.AddCulturePageRouteForSimpleContent(new CultureSegmentRouteConstraint()); routes.AddDefaultPageRouteForSimpleContent(); #endif #if (SimpleContentConfig == "b") routes.AddCultureCustomPageRouteForSimpleContent(new CultureSegmentRouteConstraint(), "NONROOTPAGESEGMENT"); routes.AddCustomPageRouteForSimpleContent("NONROOTPAGESEGMENT"); #endif #if (SimpleContentConfig == "z" || SimpleContentConfig == "b" || SimpleContentConfig == "d") routes.MapControllerRoute( name: "default-localized", pattern: "{culture}/{controller}/{action}/{id?}", defaults: new { controller = "Home", action = "Index" }, constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "def", pattern: "{controller}/{action}" , defaults: new { controller = "Home", action = "Index" } ); #endif #if (SimpleContentConfig == "c") //blog as default route routes.AddCultureBlogRoutesForSimpleContent(new CultureSegmentRouteConstraint(), ""); routes.AddBlogRoutesForSimpleContent(""); #endif return(routes); }
// this new endpoint routing has bugs that breaks folder and culture route constraints, this code could be used later after aspnetcore team fixes the bug // https://github.com/aspnet/AspNetCore/issues/14877 public static IEndpointRouteBuilder UseCustomRoutes(this IEndpointRouteBuilder routes) { routes.AddCultureBlogRoutesForSimpleContent(new CultureSegmentRouteConstraint()); routes.AddBlogRoutesForSimpleContent(); routes.AddSimpleContentStaticResourceRoutes(); routes.AddCloudscribeFileManagerRoutes(); routes.MapControllerRoute( name: "errorhandler", pattern: "oops/error/{statusCode?}", defaults: new { controller = "Oops", action = "Error" } ); routes.MapControllerRoute( name: "contact", pattern: "contact", defaults: new { controller = "Contact", action = "Index" } ); routes.MapControllerRoute( name: "api-sitemap-culture", pattern: "{culture}/api/sitemap" , defaults: new { controller = "CultureSiteMap", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "api-rss-culture", pattern: "{culture}/api/rss" , defaults: new { controller = "CultureRss", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "api-metaweblog-culture", pattern: "{culture}/api/metaweblog" , defaults: new { controller = "CultureMetaweblog", action = "Index" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "sitemap-localized", pattern: "{culture}/sitemap" , defaults: new { controller = "Page", action = "SiteMap" } , constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "sitemap", pattern: "sitemap" , defaults: new { controller = "Page", action = "SiteMap" } ); routes.MapControllerRoute( name: "default-localized", pattern: "{culture}/{controller}/{action}/{id?}", defaults: new { action = "Index" }, constraints: new { culture = new CultureSegmentRouteConstraint() } ); routes.MapControllerRoute( name: "def", pattern: "{controller}/{action}" , defaults: new { action = "Index" } ); routes.AddCulturePageRouteForSimpleContent(new CultureSegmentRouteConstraint()); routes.AddDefaultPageRouteForSimpleContent(); return(routes); }