我已经为小数创建了一个自定义模型 Binder ,但遇到了一个问题。我无法通过 Global.asax.cs
注册它,因为我没有。
如何让这条线在 startup.cs 类中起作用?
ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
最佳答案
如果引用了 System.Web.Mvc
,它将在 OWIN 启动类中正常工作。
public void Configuration(IAppBuilder app)
{
ModelBinders.Binders.Add(typeof(decimal), new DecimalModelBinder());
...
}
关于c# - Owin startup.cs 中的 ModelBinders 注册,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33084399/