Why default factory WON'T return full name of the controllers (with namespaces)? I'm using Service Locator and autofac.
using System.Web.Mvc;
using Microsoft.Practices.ServiceLocation;
namespace Application.Core.MVC
{
public override IController CreateController(System.Web.Routing.RequestContext requestContext, string **controllerName**)
{
return ServiceLocator.Current.GetInstance<IController>(controllerName);
}
}
I had two home controllers (one under area Blog)
controllerName return only "Home" without full qualified name for both in above code. This creates a problem when I try to regiser controllers' names for dependency injection. Here is how I register controllers right now according to this situation. Even this brings up the pages without exception. But When I access http://localhost/Home, both controllers invoked regardlessly.
foreach (var tp in currentAssemblyControllersTypes)
builder.Register(tp).FactoryScoped().Named(tp.Name.Replace("Controller", ""));
Anyone can help?Thanks.