我一直在使用基于ASP.NET MVC 2的XamlAsyncController,并尝试将其升级到MVC 3.但是,虽然原始应用程序工作正常,但如果我尝试运行它MVC 3,我在尝试访问ValueProvider时遇到NullReferenceException。
我已经尝试在Application_Start中显式加载默认值提供程序:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
ValueProviderFactories.Factories.Add(new RouteDataValueProviderFactory());
ValueProviderFactories.Factories.Add(new FormValueProviderFactory());
ValueProviderFactories.Factories.Add(new HttpFileCollectionValueProviderFactory());
ValueProviderFactories.Factories.Add(new QueryStringValueProviderFactory());
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
BootstrapContainer();
}
我正在使用Castle Windsor 3来管理IoC。有没有人知道为什么ControllerBase.ValueProvider会为null?