Search code examples
asp.net-mvc-3model-view-controllermodelmetadata

ability to change the ModelMetadataProviders.Current in areas


I have a special case where I would need the ability to use multiple ModelMetadaProviders in an application. Certain area would use a specific provider, another area will use some other. I mainly need this because each of those providers uses different resource file for providing resource strings.

I have it working for one and I wire it up in the global.asax.cs:

ModelMetadataProviders.Current = new LocalizedDataAnnotationsModelMetadataProvider<i18n>();

Now in the Admin area I want to do this:

ModelMetadataProviders.Current = new LocalizedDataAnnotationsModelMetadataProvider<AdminRes>();

The above doesn't work but does not throw an error also. It just doesn't do the resource string lookups.

Is this achievable and if so, how?


Solution

  • Only one can be used for the entire site. Isn't it possible to add more resource assemblies to the current LocalizedDataAnnotationsModelMetadataProvider?