Will this help? However I guess this may affect all content types - not only media.
EPiServer.Web.Routing.ContentRoute.UseTrailingSlash = false;
Hi
You should not need to do anything to prevent trailing slash for media files, the generated virtual path for media should not have a trailing slash.
Have you converted your media files from VPP based to content using the Migration tool?
Also the url for media served from globalassets should not have a language segment (that is it should not contain a "/en/" segment), that indicates that it might be the wrong route that generates the virtual path (there are different routes registered for media and e.g. pages).
Thanks, It is probably "wrong route that generates the virtual path" since i do have "en" lang code in url. How proceed with that?
Yes i used the VPP Migration tool
Debugging example:
link.NavigateUrl = "/link/2e7e4d4ba521459fbfe88e73094639c7.aspx?id=28717";
Generated link = /sv/globalassets/documents/about/corporate-governance/sv-2010-rapport.pdf/
All help is appreciated.
Regards
Could you verify that the media indeed is under GlobalAssetsRoot?
If you go to admin mode under access rigths you should see the different parts of the site under the root node. You should see a node called "For all sites" or similar, verify that the migrated media from the migration tool is located under that node.
Then from SQL Managment studio you can call
exec netContentRootList
and verify that the the id returned as GlobalAssets is the same id as the node "For all sites" described in set access rights above.
Thanks Johan,
Under "Global Assets" is all my migrated media. There is no "For all sites". And yes it is the same id as in exec netContentRootList "GlobalAssets".
What route my be wrong? how to check that?
From the description I would guess that it is the route named "pageroot" that generates the virtual path, but it should be the route named "Media". You could in a debugger in a breakpoint look at static property System.Web.Routing.RouteTable.Routes.
There you should see all routes registered and more specifiacally there should be one called "Media" before the one called "pageroot".
You can also in a debugger verify which route that generates a virtual path. You can do that by some code like:
var values = new RouteValueDictionary(); values[RoutingConstants.NodeKey] = new ContentReference(28717); var virtualPath = System.Web.Routing.RouteTable.Routes.GetVirtualPath(System.Web.HttpContext.Current.Request.RequestContext, values); var routeName = (virtualPath.Route as ContentRoute).Name;
Object VirtualPath in your code is "/EPiServer/EPiServer.Commerce.AddOns.Manager?node=28717"
We have 34 Routes
no 10 is EPiServer/EPiServer.Commerce.AddOns.Manager/{*path}
no 25 is Media_Global
no 30 is PageRoot
Suggestion?
my assumption was that 28717 is the id of an existing media item?
Anyway it seems there is some commerce route that handles the request before it reaches the cms routes. You could try to modify the code as:
var values = new RouteValueDictionary(); values[RoutingConstants.NodeKey] = new ContentReference(28717); foreach (var cmsRoute in System.Web.Routing.RouteTable.Routes.OfType<ContentRoute>()) { var virtualPath = cmsRoute.GetVirtualPath(System.Web.HttpContext.Current.Request.RequestContext, values); if (virtualPath != null) { System.Diagnostics.Debug.WriteLine("Route is " + cmsRoute.Name); } }
Yes 28717 is a PDF under globalassets.
OUTPUT:
Route is Media_Global
Route is Media_Site
Route is pageroot
.OfType<ContentRoute> sorts out to 13 Routes..
EPiServer/EPiServer.Commerce.AddOns.Manager/{*path} is typeOf System.Web.Routing.Route
Ok, so then the media route actually handles the content. What does the virtual paths look like for the different routes, e.g. change output to:
var values = new RouteValueDictionary(); values[RoutingConstants.NodeKey] = new ContentReference(28717); foreach (var cmsRoute in System.Web.Routing.RouteTable.Routes.OfType<ContentRoute>()) { var virtualPath = cmsRoute.GetVirtualPath(System.Web.HttpContext.Current.Request.RequestContext, values); if (virtualPath != null) { System.Diagnostics.Debug.WriteLine(String.Format("Route is '{0}' with path '{1}'", cmsRoute.Name, virtualPath.VirtualPath)); } }
looking good
Route is 'Media_Global' with path 'globalassets/documents/about/corporate-governance/sv-2010-bolagsstyrningsrapport.pdf'
Route is 'Media_Site' with path 'siteassets/documents/about/corporate-governance/sv-2010-bolagsstyrningsrapport.pdf'
Route is 'pageroot' with path 'globalassets/documents/about/corporate-governance/sv-2010-bolagsstyrningsrapport.pdf'
but isnt the problem that the other Routes typeOf System.Web.Routing.Route is handling the request before?
I tested:
foreach (var cmsRoute in System.Web.Routing.RouteTable.Routes.OfType<Route>()) { var virtualPath = cmsRoute.GetVirtualPath(System.Web.HttpContext.Current.Request.RequestContext, values); if (virtualPath != null) { System.Diagnostics.Debug.WriteLine("Route is " + cmsRoute.Url + " // " + cmsRoute.RouteHandler.ToString()); } }
Route is EPiServer/EPiServer.Commerce.AddOns.Manager/{*path} // System.Web.Mvc.MvcRouteHandler
Route is ProductInCartOrWishList/Edit/{id} // System.Web.Mvc.MvcRouteHandler
Route is CustomerProperties/Edit/{id} // System.Web.Mvc.MvcRouteHandler
Route is OrdersFrequency/Edit/{id} // System.Web.Mvc.MvcRouteHandler
Route is RecentSpent/Edit/{id} // System.Web.Mvc.MvcRouteHandler
Route is RecentOrders/Edit/{id} // System.Web.Mvc.MvcRouteHandler
Route is // EPiServer.Web.Routing.MultiplexingRouteHandler
Route is // EPiServer.Web.Routing.MultiplexingRouteHandler
Route is // EPiServer.Web.Routing.MultiplexingRouteHandler
Thank you for helping, routing is not my domain.
If another route than a CMS route would have taken the request then the url would probably have been something like the ones you see above. But in your case it looks almost correct except for the language segment and the trailing slash.
Could it be that you have some old custom FURL module running. If you look in your config under http modules do you see an entry of EPiServer.Web.RoutingUrlRewriteModule? And also under <episerver> section is there any node <urlRewrite> and if so what is the content there?
yes we do have in episerver.config...
<urlRewrite defaultProvider="EPiServerFriendlyUrlRewriteProvider"> <providers> <clear /> <add name="EPiServerFriendlyUrlRewriteProvider" type="EPiServer.Web.FriendlyUrlRewriteProvider,EPiServer" /> <add description="EPiServer identity URL rewriter" name="EPiServerIdentityUrlRewriteProvider" type="EPiServer.Web.IdentityUrlRewriteProvider,EPiServer" /> <add description="EPiServer bypass URL rewriter" name="EPiServerNullUrlRewriteProvider" type="EPiServer.Web.NullUrlRewriteProvider,EPiServer" /> <add name="HierarchicalUrlRewriteProvider" type="EPiServer.Web.HierarchicalUrlRewriteProvider,EPiServer" /> </providers> </urlRewrite>
Try to either outcomment the whole section or change defaultProvider to HierarchicalUrlRewriteProvider
Yes, previously to CMS7 we had our own routing framework (UrlRewriteProviders), from CMS7 and forward we have a new implemenation based on .NET routing. The reason the old one is still possible to run is to support if someone has written their own UrlRewriteProvider with custom logic.
Johan, yesterday i did only look the html output.... now when i click the link or type in "/globalassets/report.pdf"
it does a 302 redir and put a trailing trash "/globalassets/report.pdf/" in the webadress, doh! (no good for siteseeker indexer)
I have removed FriendlyUrlRewriteProvider from web.config, default is set to "HierarchicalUrlRewriteProvider".
Same if i remove all UrlRewrite providers in Episerver.config
If I set EPiServer.Web.Routing.ContentRoute.UseTrailingSlash = false; it works, but i want tailing slash on all other URLs except mediafiles...
Any idea what now?
I could use UrlRewrite in IIS but i would like to find the root cause.
If you look in web.config under httpmodules, do you have an entry of EPiServer.Web.RoutingUrlRewriteModule? If you instead have an entry of type EPiServer.Web.UrlRewriteModule try to change to EPiServer.Web.RoutingUrlRewriteModule.
Hi all,
Update from CMS6r2 to CMS v 7.19.2 (webforms)
I have a trailing slash by default on mediafiles (domain.com/en/globalassets/folder/filename.pdf/), and i don want that.
I want to remove trailing slashes on mediafiles. Shouldn't that automaticly? Any suggestions?
Tried the IIS rewrite 2.0 on IIS7, but i didnt get it to work other then the root page. It makes eternal redirects on all other pages.
Regards