Skip to content

Instantly share code, notes, and snippets.

@nul800sebastiaan
Last active March 21, 2020 08:21
Show Gist options
  • Save nul800sebastiaan/927dcf155439fcc867e97a4d8dda6e16 to your computer and use it in GitHub Desktop.
Save nul800sebastiaan/927dcf155439fcc867e97a4d8dda6e16 to your computer and use it in GitHub Desktop.
For v6 and v7 sites
using System.Web.Routing;
using Umbraco.Core;
namespace RemoveRoutes
{
public class RemoveRoutesStartupHandler : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
// Reference: https://github.com/umbraco/Umbraco-CMS/issues/5206
// Reference: https://shazwazza.com/post/need-to-remove-an-auto-routed-controller-in-umbraco/
// Note: RouteTable needs System.Web.dll
RouteTable.Routes.Remove(RouteTable.Routes["umbraco-surface-UmbRegister"]);
RouteTable.Routes.Remove(RouteTable.Routes["umbraco-surface-UmbProfile"]);
RouteTable.Routes.Remove(RouteTable.Routes["umbraco-surface-UmbLogin"]);
RouteTable.Routes.Remove(RouteTable.Routes["umbraco-surface-UmbLoginStatus"]);
RouteTable.Routes.Remove(RouteTable.Routes["umbraco-api-Tags"]);
}
}
}
@bobi33
Copy link

bobi33 commented Mar 20, 2020

Hi, do we delete the .cs file from App_Data once we run the website on the public server, or does it stay in there?

@nul800sebastiaan
Copy link
Author

@bobi33 It has to stay in place.. it's the only thing protecting you if you do not upgrade to the latest version of Umbraco,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment