开发者

MVC2 to MVC3 IOC problem

开发者 https://www.devze.com 2023-03-19 00:32 出处:网络
I just migrated from MVC2 to MVC3 and I got the following error when I build the project : RhinoIoCControllerFactory does not implement interface member System.Web.Mvc.IControllerFactory.GetControlle

I just migrated from MVC2 to MVC3 and I got the following error when I build the project :

RhinoIoCControllerFactory does not implement interface member System.Web.Mvc.IControllerFactory.GetControllerSessionBehavior(System.WebRouting.RequestContext,string)

Here is rhe class where the error come from :

        public class RhinoIoCControllerFactory : IControllerFactory
        {

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

            pu开发者_Go百科blic void ReleaseController(IController controller)
            {
                IoC.Container.Release(controller);
            }

        }

Any ideas ?

Thanks


You need to implement the MVC3 method. The following will fix it:

  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

0

精彩评论

暂无评论...
验证码 换一张
取 消