Reputation: 41
I've created a custom model binder for decimals but stuck with a problem. I can't register it via Global.asax.cs
because I don't have one.
How to make this line work in startup.cs class?
ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
Upvotes: 4
Views: 709
Reputation: 33833
It will work in an OWIN startup class just fine provided System.Web.Mvc
is referenced.
public void Configuration(IAppBuilder app)
{
ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
...
}
Upvotes: 1