Try our conversational search powered by Generative AI!

URL Routing for Media Assets

Vote:
 

We currently have existing CDN URLs without trailing slash in the URL (http://SITEURL/cdn-/Resources/shared/css/layout-v2.5.0.css) When adding a Asset Route to handle the CDN Assets we get a 404 before we can handle the request. When adding a trailing slash in the URL the route request gets dealt with and we can handle the request. It seems like the generation of the global assets have the trailing slash.

Our CDN URLs with this route works but only with the trailing slash in URL:

routes.MapAssetRoutes("CDNMedia", "/cdn/cdn-{timestamp}/MediaStaticPlaceHolder/{node}/{partial}/{action}",
new
{
action = "index"
}, "MediaStaticPlaceHolder", "globalassets", "siteassets");

Have also tried setting the static variable for trailing slashes to false in our Application_Start:

EPiServer.Web.Routing.ContentRoute.UseTrailingSlash = false;

Is there a way of dealing with Content Routes without the trailing slash?

#122401
Jun 02, 2015 10:45
Vote:
 

does this answer you? http://world.episerver.com/blogs/K-Khan-/Dates/2014/12/using-blobs-and-cdn-both-effectively/
another related topic is http://world.episerver.com/blogs/K-Khan-/Dates/2014/12/trailing-slashes-in-website/
Regards
/K

#122414
Jun 02, 2015 12:54
Vote:
 

Thanks for your response. This got me thinking about the managed pipeline and the modules being ran with the routing and come across a web.config setting which was not set which means the resource assets (css, js) etc weren't being routed/handled, that's why the default EPiServer content asset URLs with the appending slash caused the routing and handling for those resources to work.

Adding the setting runAllManagedModulesForAllRequests fixed the issue <modules runAllManagedModulesForAllRequests="true">

I have read concerns around performance as all requests (css etc) go through the modules defined but this hasn't seemed to effect the performance. 

Also for reference, not sure if this helps anyone but I found that a perm fix for the trailing slash in my case was to override the FriendlUrlRewriteProvider.ConvertToExternalInternal, as this generates the contents URL using GetFriendlyPagePath which ultimately calls into VirtualPathUtility.AppendTrailingSlash.

#122454
Jun 03, 2015 3:10
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.