title: Custom Model Binder for decimals and integer: How to get the string value before MVC and do a smarter conversion
body: <p>I want to extend the default model binding to be more smart when dealing with numbers. The default works very bad when are commas and decimals points in the game.</p>
  
  <p>I was trying the do a new binder</p>
  
  <pre><code>Public Class SmartModelBinder
      Inherits DefaultModelBinder
      Protected Overrides Sub SetProperty(controllerContext As ControllerContext, bindingContext As ModelBindingContext, propertyDescriptor As System.ComponentModel.PropertyDescriptor, value As Object)
          If propertyDescriptor.PropertyType Is GetType(Decimal) Or propertyDescriptor.PropertyType Is GetType(Decimal?) Then
              If value Is Nothing Then
                  value = 0
              End If
          End If
  
          MyBase.SetProperty(controllerContext, bindingContext, propertyDescriptor, value)
      End Sub
  End Class
  </code></pre>
  
  <p>But the value is already converted at this point</p>
  
  <p><strong>How can I extend the binder to get the string value from the form and perform a different transformation?</strong></p>