Skip to content

Instantly share code, notes, and snippets.

@siddharth-pandey
Created November 18, 2014 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddharth-pandey/a4a168ca2e9067fe6971 to your computer and use it in GitHub Desktop.
Save siddharth-pandey/a4a168ca2e9067fe6971 to your computer and use it in GitHub Desktop.
public class ComponentDataModelBinder : DefaultModelBinder
{
protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType)
{
var type = typeof(ComponentData);
var model = Activator.CreateInstance(type);
bindingContext.ModelMetadata = ModelMetadataProviders.Current.GetMetadataForType(() => model, type);
return model;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment