在 Global.asax 中为 string 类型指定这个 ModelBinder
protected void Application_Start()
{
ModelBinders.Binders.Add(typeof(string), new StringTrimModelBinder());
//...
}
protected void Application_Start()
{
ModelBinders.Binders.Add(typeof(string), new StringTrimModelBinder());
//...
}