Trailing slash on mediafiles

Member since: 2007

Hi all,

Update from CMS6r2 to CMS v 7.19.2 (webforms)

I have a trailing slash by default on mediafiles (, 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.


#120166 Apr 13, 2015 8:46
  • Member since: 2011

    Will this help? However I guess this may affect all content types - not only media.

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


    #120170 Edited, Apr 13, 2015 10:04
  • Member since: 2007

    No, niether true or false do any difference.

    #120171 Apr 13, 2015 10:21
  • Member since: 2004


    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).

    #120175 Apr 13, 2015 11:33
  • Member since: 2007

    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.


    #120179 Apr 13, 2015 11:49
  • Member since: 2004

    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.

    #120187 Apr 13, 2015 13:37
  • Member since: 2007

    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?

    #120189 Apr 13, 2015 13:48
  • Member since: 2004

    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;

    #120190 Apr 13, 2015 14:09
  • Member since: 2007

    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


    #120192 Apr 13, 2015 15:29
  • Member since: 2004

    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);

    #120193 Apr 13, 2015 15:39
  • Member since: 2007

    Yes 28717 is a PDF under globalassets.


    Route is Media_Global
    Route is Media_Site
    Route is pageroot

    .OfType<ContentRoute> sorts out to 13 Routes..

    #120194 Apr 13, 2015 15:51
First   1 2 3   Last