別のアセンブリからController
をロードしようとしていますが、私はここで止まっています。私はRoute
をWebアプリケーションでコントローラが別のアセンブリからロードされていませんか?
- Webアプリケーション
- クラスライブラリ
定義さ:
routes.MapRoute("Root", "root/{Action}",
new {Controller = "Root", Action = "Index" });
今、私は次のように打ったとき、私は二つのプロジェクトを持っている
URLでは、ルートは一致しますが、404エラーがスローされます。 これはなぜ起こっているのか誰にでも教えてもらえますか?
:私もルートにnamespaces
プロパティを追加しようとした 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??
}
}
:
http://webapp/root
私はカスタムコントローラファクトリを追加しようとしました(PS RootController
は、クラスライブラリにあります)
routes.MapRoute("Root", "root/{Action}",
new {
Controller = "Root",
Action = "Index",
Namespaces = new[] { typeof(RootController).Namespace }
});
問題を再現できません。 –
@Max Toro、私の答えを見てください... – Ropstah