我已经迁移了MVC1项目MVC2RC,现在该网站不在所有的工作。我得到了错误的"进入点没有被发现。"

我迁移的项目下 这个链接

我使用的是温莎城堡作为DI。

这里是一个部分的全球性的。asax.cs

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

        routes.MapRoute(
            "Default", "{controller}/{action}/{id}", new { controller = "Main", action = "Index", id = "" });
    }

    protected void Application_Start()
    {
        log4net.Config.XmlConfigurator.Configure();
        InitializeServiceLocator();
        //RouteConfigurator.RegisterRoutesTo(RouteTable.Routes);
        AreaRegistration.RegisterAllAreas();
        RegisterRoutes(RouteTable.Routes);

        Bootstrapper.BootStrap();
    }

    /// <summary>
    /// If you need to communicate to multiple databases, you'd add a line to this method to
    /// initialize the other database as well.
    /// </summary>
    private void InitializeNHibernateSession()
    {
        var cfg =
            NHibernateSession.Init(
                webSessionStorage,
                new string[] { Server.MapPath("~/bin/Edi.Advance.EPortfolio.Data.dll") },
                new AutoPersistenceModelGenerator().Generate(),
                Server.MapPath("~/hibernate.cfg.xml")).AddAssembly(typeof(ISoftDeletable).Assembly).AddAssembly(
                typeof(Action).Assembly);

        //cfg.SetListener(ListenerType.Delete, new AdvanceDeleteEventListener(IoC.Resolve<ISecurityContextService>()));
        //cfg.SetListener(ListenerType.SaveUpdate, new AdvanceSaveUpdateEventListener(IoC.Resolve<ISecurityContextService>()));
    }

    /// <summary>
    /// Instantiate the container and add all Controllers that derive from 
    /// WindsorController to the container.  Also associate the Controller 
    /// with the WindsorContainer ControllerFactory.
    /// </summary>
    protected virtual void InitializeServiceLocator()
    {
       // AddComponentsToIoC();
        var container = new WindsorContainer();

        ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));
        container.RegisterControllers(typeof(MainController));

        ServiceLocator.SetLocatorProvider(() => new WindsorServiceLocator(container));

    }

MainController是非常简单,指数的行动只是返回"hello world从MVC2"string.(不认为这种行动)。

有趣的事情是如果我出评论这一行:

ControllerBuilder.Current.SetControllerFactory(new WindsorControllerFactory(container));

MainController工作良好,但是会导致其他更复杂的控制器不适用说,没有无参构造。

所以缝那是错误的东西与WindsorControllerFactory.

任何想法?感谢

有帮助吗?

解决方案

使用:受保护的复盖IController GetControllerInstance(系统。网。路由。RequestContext requestContext,型controllerType)

而不是:受保护的复盖IController GetControllerInstance(类型controllerType)

其他提示

使用:
受保护的复盖IController GetControllerInstance(系统。网。路由。RequestContext requestContext,型controllerType)

而不是:
受保护的复盖IController GetControllerInstance(类型controllerType)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top