1

I've removed code that is shared between two applications into a shared project which includes controllers. Im getting the "Multiple types were found that match the controller named" error. I'm not sure why this is happening. So this is my shared controller

namespace App.Web.Shared.Controllers
{
  public class ParkingTicketController : BaseController
  {
    public ParkingTicketController(ServiceLocator serviceLocator) : base(serviceLocator)
    {
    }

    /// <summary>
    /// Views the specified identifier.
    /// </summary>
    /// <param name="publicId">The public identifier.</param>
    /// <returns></returns>
    [AuthorizeAccess(Roles = ApplicationRoles.None)]
    public ActionResult Display(string publicId)
    {
        //Shared
    }
}
}


 namespace App.Web.Driver.Controllers
{
[AuthorizeAccess(Roles = ApplicationRoles.Driver)]
public class ParkingTicketController :   Shared.Controllers.ParkingTicketController
{
    //
    // GET: /ParkingTicket/

    /// <summary>
    /// Initializes a new instance of the <see cref="ParkingTicketController"/> class.
    /// </summary>
    /// <param name="serviceLocator">The service locator.</param>
    public ParkingTicketController(ServiceLocator serviceLocator) : base(serviceLocator)
    {
    }
 }

}

This is the route set up. So it should match the driver Controller

routes.MapRoute(
     name: "Default",
     url: "{controller}/{action}/{id}",
     defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional},
                     namespaces: new[] { "App.Web.Driver.Controllers" });

I'm simply calling it from my view

@Html.ActionLink("View Print", "Display", "ParkingTicket", new { id = Model.ParkingTicket.PublicId }, new { @class = "btn btn-blue" })

Error message

enter image description here

1 Answer 1

2

If you never want your shared controller to serve any requests, then you can define the default namespaces to look in; taken from here:

ControllerBuilder.Current.DefaultNamespaces.Clear();
ControllerBuilder.Current.DefaultNamespaces.Add("App.Web.Driver.Controllers");

And that should restrict any lookups to just your main namespace. If you add another important namespace, then you'd have to add it to this list.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.