Ich versuche eine Controller
von einer anderen Baugruppe zu laden, aber ich stecke hier fest.Controller nicht von anderer Baugruppe geladen?
Ich habe zwei Projekte:
- Webanwendung
- Bibliothek Klasse
In der Web-Anwendung definiert ich eine Route
:
routes.MapRoute("Root", "root/{Action}",
new {Controller = "Root", Action = "Index" });
Nun, wenn ich die folgende Hit URL, die Route ist abgestimmt, jedoch wird ein 404-Fehler ausgelöst. Kann mir jemand sagen, warum das passiert? (ps die RootController
ist in der Klassenbibliothek befindet)
http://webapp/root
Ich habe versucht, eine benutzerdefinierte Controller Factory hinzufügen:
public class ControllerFactory : DefaultControllerFactory {
protected override IController GetControllerInstance(RequestContext reqContext, Type controllerType)
{
// reqContext.Route is correct and has the "Root" route loaded
// controllerType seems to be null ??
// if I break execution here and manually set controllerType to
// typeof(ClassLibrary.RootController) and continue from there,
// then everything works as expected...
// So this method is being called without controllerType... but why??
}
}
Ich habe auch versucht eine namespaces
Eigenschaft auf die Route hinzufügen:
routes.MapRoute("Root", "root/{Action}",
new {
Controller = "Root",
Action = "Index",
Namespaces = new[] { typeof(RootController).Namespace }
});
Kann das Problem nicht reproduzieren. –
@Max Toro, siehe meine Antwort ... – Ropstah