Andrew Budyashevskiy
Andrew Budyashevskiy

Reputation: 41

ModelBinders registration in Owin startup.cs

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

Answers (1)

David L
David L

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

Related Questions