从迁移.NET MVC 1到MVC 2 RC [英] Migrate from .NET MVC 1 to MVC 2 RC

查看:84
本文介绍了从迁移.NET MVC 1到MVC 2 RC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经迁移的MVC1项目MVC2 RC,现在的网站没有在所有的工作。我得到的错误入口点没有被发现。

I've migrated a MVC1 project to MVC2 RC, and now the site doesn't work at all. I get the error "Entry point was not found."

我移植后的项目<一个href=\"http://weblogs.asp.net/leftslipper/archive/2009/10/19/migrating-asp-net-mvc-1-0-applications-to-asp-net-mvc-2.aspx\"相对=nofollow>此链接

我使用温莎城堡作为DI。

I'm using Castle Windsor as DI.

下面是的global.asax.cs的一部分

Here is a part of global.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字符串。 (此操作的观点)。

MainController is very simple, Index action just return "Hello world from MVC2" string. (No view for this action).

有趣的事情是,如果我注释掉这一行:

The interesting things is if I comment out this line:

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

MainController工作正常,但导致其他更复杂的控制器不工作说没有参数的构造函数。

MainController works fine, but of cause other more complicated controllers do not works saying that there is no parameterless constructor.

所以,接缝是什么毛病WindsorControllerFactory。

So it seams that is something wrong with WindsorControllerFactory.

任何想法?
谢谢

Any ideas? Thanks

推荐答案

使用:
保护覆盖一个IController GetControllerInstance(System.Web.Routing.RequestContext的RequestContext,类型controllerType)

Use: protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)

的insted的:
保护覆盖一个IController GetControllerInstance(类型controllerType)

Insted of: protected override IController GetControllerInstance(Type controllerType)

这篇关于从迁移.NET MVC 1到MVC 2 RC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆