November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi
Below is an example of an override of RegisterRoutes in Global.asax.cs that does the replacement of media route
protected override void RegisterRoutes(System.Web.Routing.RouteCollection routes) { base.RegisterRoutes(routes); int mediaRouteIndex = 0; //Find out index of media route so we can replace it at same location for (int i =0 ; i <routes.Count; i++) { var contentRoute = routes[i] as ContentRoute; if (contentRoute != null && contentRoute.Name.Equals("Media_Global")) { mediaRouteIndex = i; break; } } if (mediaRouteIndex != 0) { routes.RemoveAt(mediaRouteIndex); routes.MapContentRoute( name: "Media_Global", url: "media/{node}/{partial}/{action}", defaults: new { action = "index" }, contentRootResolver: sd => sd.GlobalAssetsRoot); //The media route is now added last, move it to previous location var mediaRoute = routes.Last(); routes.RemoveAt(routes.Count - 1); routes.Insert(mediaRouteIndex, mediaRoute); } }
I was searching for a way to edit the path of all media files (change 'globalassets' into 'media') and stumbled upon this forum post.
I'm actually surprised it got so little attention, I would assume that more developers have come across this requirement.
The solution as mentioned in the post is quite brief. I understand it's a matter of replacing the existing routing for assets to a new one, changing the static segment along the way.
But my question is: how do I know which one is the routing for the assets, the one I need to replace?
I tried removing several of the routings, assuming at some point to see broken images, but this didnt happen.
Does anyone have some good pointers on how to set this up? Apart from the ones already mentioned in the other post...
Cheers, Reinder