A very common SEO requirement is to ensure that each page on your website has a unique URL. Google will treat www.website.com/page1 and www.website.com/page1/ as different URLs. In this tutorial, you will learn how to configure Episerver so that all the URLs that Episerver generates either includes, or, excludes a trailing slash.
Configuring Episerver to either include, or, remove a trailing slash can be done via the 'RoutingOptions' API. Like everything Epsierver, you can use an API to configure EPiserver.
public void ConfigureRoutes()
var routingOptions = ServiceLocator.Current.GetInstance<RoutingOptions>();
routingOptions.UseTrailingSlash = false; // true to add one
To get access to the 'RoutingOptions' API you can inject it using the ServiceLocator. When you get access to the API, you can use the 'UseTrailingSlash' property. For reference, you can also do the same thing yourself in code. To learn more about that you can check out this article.
As a bonus, you can also configure Episerver to render all links as lowercase. This can be done using this API.
EPiServer.Web.UrlSegment.UseLowerCaseSegments = true;
Now you know about the API'S you need to use and how to use them, the next step is to add the code to your solution. The best place to add this configuration code is either within your global.ascx, or, an initialization module.
Software Architect, Programmer and Technologist Jon Jones is founder and CEO of London-based tech firm Digital Prompt. He has been working in the field for nearly a decade, specializing in new technologies and technical solution research in the web business. A passionate blogger by heart , speaker & consultant from England.. always on the hunt for the next challenge