Well, if you intend to write the entire binder from scratch, you will not have a model. Instead you'd actually be the one creating the model (since that's what the binder is for), from the form data. Such as:
return new SomeModel
{
OneProp = request.Form["OneProp"],
AnotherProp = request.Form["AnotherProp"]
}
Alternatively you can inherit from DefaultModelBinder
instead of IModelBinder
, which you can use to extend only certain behavior instead of actually handling the construction of the model.
EDIT:
From your comments I'm understanding that you are only wanting to process one property in several viewmodels you might have (possibly multiple viewmodels have decimals that come from the view in a different format than what MVC expects for decimals.
In that case I'd actually use a different approach. Instead of registering the ModelBinder in global.asax, I'd remove it from there and do it declaratively on the actual properties that need that special format.
Such as:
[PropertyBinder(typeof(MyDecimalBinder))]
public decimal SomePropInAViewModel {get; set;}
This is based on a common approach of creating the PropertyBindingAttribute:
http://www.prideparrot.com/blog/archive/2012/6/customizing_property_binding_through_attributes or https://stackoverflow.com/a/12683210/1373170
And with a ModelBinder similar to this:
public class MyDecimalBinder : DefaultModelBinder {
protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor) {
// use the propertyDescriptor to make your modifications, by calling SetProperty()
...
base.BindProperty(controllerContext, bindingContext, propertyDescriptor);
}
}
Now, if this is something you want applied to ALL decimals, you might also want to check out Phil Haack's full implementation on handling decimals using a custom binder:
http://haacked.com/archive/2011/03/19/fixing-binding-to-decimals.aspx/