What are you trying to achieve with that route? There might be better ways of solving your requirement.
Routing has changed a lot between .NET Framework and .NET Core.
Thanks for the reply Johan.
We are storing assets in the CMS and we would like to remove the globalassets portion of the url. We are using this as a safety net from our old website.
before, right now it's /globalassets/publishingimages and we want /publishingimages
In CMS 11, we were achieving this with the above code.
Hi OlivierG,
I believe you can achieve what you're looking for with:
public sealed class PublishingImagesRouteRegistration : IContentRouteRegister
{
public ContentRouteDefinition ContentRouteDefintion => new ()
{
Name = nameof(PublishingImagesRouteRegistration),
RouteRootResolver = s => s.GlobalAssetsRoot,
ContextMode = RouteContextMode.All,
SupportMultiLanguage = false,
StaticSegments = new[] { "publishingimages" },
};
}
you need to register this in services with:
services.AddTransient<IContentRouteRegister, PublishingImagesRouteRegistration>();
I've tested in briefly in Alloy, but more extensive tests will be needed on your side.
1 vote for Karol Berezicki. Yes, it is break change with routing in CMS 12. We can add more implementation for IContentRouteRegister to register route. I saw this code works in Alloy. The default route for global assets is replaced by new one.
Hello,
In v11, we had a custom route for our assets in our Global.asax. We are trying to find an equivalence in v12.
This was our original code:
routes.MapAssetRoutes(
name: "PublishingImages",
url: "/{node}/{partial}/{action}",
defaults: new { action = "index" },
staticSegmentPlaceHolder: EPiServer.Web.Routing.RouteCollectionExtensions.MediaStaticSegmentPlaceHolder,
globalReplacement: "publishingimages",
siteReplacement: EPiServer.Web.Routing.RouteCollectionExtensions.SiteAssetStaticSegment);
Any suggestions?