November Happy Hour will be moved to Thursday December 5th.

Use Trailing Slash

Vote:
 

Hi,

How do I make sure UseTrailingSlash is set to true? Do I add the following to my global.asax Application_Start or is it something that has to be activated in web.config? 

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

My mission is to make www.mysite.com/url to automaticly add a slash at the end, so it ends up www.mysite.com/url/ when the user tries to access it.

Thanks!

#112523
Oct 29, 2014 15:17
Vote:
 

It is just a static boolean property that you typically you would like to set during initialization so you could do it either in Application_Start or in an IInitializableModule.

#112576
Oct 30, 2014 12:00
Vote:
 

Thanks Johan, It worked for me.
Regards
/K

#112809
Nov 05, 2014 16:49
Vote:
 

What am i doing wrong:

I want to add the slash and also make the url lowercase..

this is my initialization module but url stays the same without slash and no lowercase: 

Am i doing something wrong?

[InitializableModule]
    [ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
    public class RoutingInitialization : IInitializableModule
    {
        public void Initialize(InitializationEngine context)
        {
            //Add initialization logic, this method is called once after CMS has been initialized
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            EPiServer.Web.Routing.ContentRoute.UseTrailingSlash = true;
            EPiServer.Web.UrlSegment.UseLowerCaseSegments = true; 
        }

        public void Preload(string[] parameters) { }

        public void Uninitialize(InitializationEngine context)
        {
            //Add uninitialization logic
        }
    }
#131732
Aug 04, 2015 13:41
* 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.