7

I upgraded my site from 7.5 to 8.1 and when I try to click on Sitecore logout link I have the following error:

    Multiple types were found that match the controller named 'Authentication'. 
    This can happen if the route that services this request ('sitecore/shell/api/sitecore/{controller}/{action}') 
    does not specify namespaces to search for a controller that matches the request. If this is the case,
    register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' 
    parameter.   
    The request for 'Authentication' has found the following matching controllers:
    Sitecore.Controllers.AuthenticationController
    A.B.Controllers.AuthenticationController

My question is how I can change the controller name for Sitecore logout to use the full name of the controller I mean with namespace?

2
  • Is ` A.B.Controllers.AuthenticationController` a custom controller you have created?
    – Richard Seal
    Sep 28 '16 at 12:58
  • Yes it is a custom controller Sep 28 '16 at 15:13
4

The simplest solution here seems to be to update your custom controller A.B.Controllers.AuthenticationController to have a unique name so that it doesn't conflict with the Sitecore one.

The risk of trying to change the Sitecore references to that controller are high and it would potentially make any future upgrades more complex as you would have to make sure that customization was carried over. I would just change your custom A.B.Controllers.AuthenticationController to a new name or a new Area and that should solve the issue.

1
  • This is related to a shared component which I can't update right now. Sep 28 '16 at 16:32
2

You should use method RouteTable.Routes.MapRoute

Here is the documentation for it from MSDN.

You are interested in this call:

public static Route MapRoute(
    this RouteCollection routes,
    string name,
    string url, // this is the url you should match
    object defaults,
    string[] namespaces // here you can define the namespace(s) you want to use
)

UPDATE

The MapRoute method can be used to map url to a certain controller and action. In case of conflicting names it allows you to specify two different urls (routes) so that MVC knows which controler to use

eg.

if you have two controllers for Settings - Special.Controllers.FooController and Controllers.FooController you can use MapRoute in a following way:

MapRoute("Special_route", "/special/{controller}/{action}", new {}, new [] { "Special.Controllers" })
MapRoute("Regular_route", "/{controller}/{action}", new {}, new [] { "Controllers" })

However in your case this might not be a good approach.

Sitecore's MVC model is slightly different from the pure ASP.NET MVC and almost all request are routed throug single route sitecore/shell/api/sitecore/{controller}/{action}. Thus you could only replace Sitecore controller but this might not be a good idea.

I would agree with Richard's suggestion to rename your controller.

4
  • I tried this on the Application_Start Global.asax file event and still have the same error. Sep 28 '16 at 16:31
  • Following is the code that I used: routes.MapRoute( "SCAuth", "sitecore/shell/api/sitecore/{controller}/{action}", new { controller = "Authentication", action = "Index"}, new[] { "Sitecore.Controllers" } ); Sep 28 '16 at 16:31
  • I have updated my answer. In general I would go with renaming your controller if this is possible. Sep 28 '16 at 19:10
  • 1
    You might find you have to update the routes in the Init pipeline, after the Sitecore MVC routes are added, rather than in Global before they are added. You can remove routes too. In principle, though, @RichardSeal has the right approach. Sep 28 '16 at 20:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.