Here are some changes that affected my asp mvc update process, specifically ASP .NET MVC2 Changes: GetControllerInstance & DataAnnotationsModelBinder.
By the way, there is a tool that does it for you and also a manual way .
But once you have updated there are also 2 more changes that you may need if you are using IoC or DataAnnotations.
First you will need to change the method in your Ioc to look for controller
|
1 2 3 4 5 6 7 8 9 10 |
public class CommonServiceLocatorControllerFactory : DefaultControllerFactory { protected override IController GetControllerInstance(Type controllerType) { if (controllerType == null) base.GetControllerInstance(controllerType); return ServiceLocator.Current.GetInstance(controllerType) as IController; } } |
into, notice the RequestContext in the parameter
|
1 2 3 4 5 6 7 8 9 10 |
public class CommonServiceLocatorControllerFactory : DefaultControllerFactory { protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType) { if (controllerType == null) base.GetControllerInstance(requestContext, controllerType); return ServiceLocator.Current.GetInstance(controllerType) as IController; } } |
The other change is in DataAnnotationsModelBinder if you have one, rather than inherit from Microsoft.Web.Mvc.DataAnnotations.DataAnnotationsModelBinder inherit from DefaultModelBinder
Hope this helps 🙂

Leave a Reply