Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
For v8 sites
using System.Web.Routing;
using Umbraco.Core.Composing;
using Umbraco.Web.Runtime;
namespace RemoveRoutes
{
// This is required to ensure this composer runs after
// Umbraco's WebFinalComposer which is the component
// that creates all of the routes during startup
[ComposeAfter(typeof(WebFinalComposer))]
public class RemoveRoutesComposer : ComponentComposer<RemoveRoutesComponent>
{
}
//The component that runs after WebFinalComponent
//during startup to modify the routes
public class RemoveRoutesComponent : IComponent
{
public void Initialize()
{
// 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"]);
}
public void Terminate()
{
}
}
}
@nul800sebastiaan

This comment has been minimized.

Copy link
Owner Author

commented Jul 30, 2019

@nul800sebastiaan

This comment has been minimized.

Copy link
Owner Author

commented Jul 31, 2019

Note: As per the comment here, the Tags route was just updated to be umbraco-api-Tags: https://gist.github.com/nul800sebastiaan/927dcf155439fcc867e97a4d8dda6e16#gistcomment-2984807

@firthy

This comment has been minimized.

Copy link

commented Aug 9, 2019

Hi,
When i add the fix to sites running 8.0.0 i get the following error:

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0246: The type or namespace name 'WebFinalComposer' could not be found (are you missing a using directive or an assembly reference?)

Source Error:

Line 8: // Umbraco's WebFinalComposer which is the component
Line 9: // that creates all of the routes during startup
Line 10: [ComposeAfter(typeof(WebFinalComposer))]
Line 11: public class RemoveRoutesComposer : ComponentComposer
Line 12: {

It OK in later versions.
Any ideas?

Cheers,
Mark

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.