MVC2到MVC3 IOC问题

时间:2011-07-10 15:54:45

标签: asp.net-mvc-3 ioc-container

我刚刚从MVC2迁移到MVC3,我在构建项目时遇到以下错误:

RhinoIoCControllerFactory没有实现接口成员System.Web.Mvc.IControllerFactory.GetControllerSessionBehavior(System.WebRouting.RequestContext,string)

这是错误的来自:

        public class RhinoIoCControllerFactory : IControllerFactory
        {

            public IController CreateController(RequestContext requestContext, string controllerName)
            {
                return IoC.Resolve<IController>((controllerName + "Controller").ToLower());
            }

            public void ReleaseController(IController controller)
            {
                IoC.Container.Release(controller);
            }

        }

有什么想法吗?

由于

1 个答案:

答案 0 :(得分:12)

您需要实现MVC3方法。以下将解决它:

  public SessionStateBehavior GetControllerSessionBehavior(RequestContext requestContext, string controllerName)
  {
    return SessionStateBehavior.Default;
  }

http://blog.janjonas.net/2011-05-30/aspnet-mvc-fix-icontrollerfactory-implementation-upgrading-mvc_2-mvc_3