public static class MVCHellper { public static string GetErrors(ModelStateDictionary ms) { System.Text.StringBuilder sbtext = new System.Text.StringBuilder(); foreach (var item in ms.Keys) { if (ms[item].Errors.Count <= 0) { continue; } sbtext.Append("错误消息为:"); foreach (var itemerror in ms[item].Errors) { sbtext.Append(itemerror.ErrorMessage + "<br/>"); } } return sbtext.ToString(); } }