Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC2 to MVC3 IOC problem

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());
            }

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

        }

Any ideas ?

Thanks

like image 438
user508945 Avatar asked Dec 16 '22 12:12

user508945


1 Answers

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

like image 106
NinjaNye Avatar answered Dec 29 '22 10:12

NinjaNye