void Executing(HttpActionContext filterContext) { object parameter = filterContext.GetActionParameterValue(ParamName); if (parameter == null || parameter.GetType().IsPrimitive) { return; } var p = parameter.GetType().GetProperty(PropertyName, Reflection.BindingFlags.IgnoreCase | Reflection.BindingFlags.Instance | Reflection.BindingFlags.Public); if (p == null) { return; } HttpContextBase context = (HttpContextBase)filterContext.Request.Properties["MS_HttpContext"];//获取传统context HttpRequestBase request = context.Request;//定义传统request对象 string propertyParamName = string.IsNullOrEmpty(PropertyParamName) ? PropertyName : PropertyParamName; string value = request[propertyParamName]; if (value == null) { value = filterContext.ControllerContext.RouteData.Values[propertyParamName] as string; } if (!string.IsNullOrEmpty(value)) { try { if (Type.IsPrimitive || Type.Equals(typeof(string)) || Type.Equals(typeof(Decimal))) { p.SetValue(parameter, Convert.ChangeType(value, Type)); } else { var result = ParameterConvert.Convert(value, this.Type); p.SetValue(parameter, result); } } catch //(Exception ex) { } } }