protected override IDictionary <string, object> GetParameterValues(ControllerContext controllerContext, ActionDescriptor actionDescriptor) { ThriftActionResult context = ThriftActionResult.GetThriftResult(controllerContext.HttpContext); //check if current request is thrift if (context != null && context.GetParameterValues != null) { Dictionary <string, object> parameterDictionary = new Dictionary <string, object>(); context.GetParameterValues(context.Input, parameterDictionary); context.Parameters = parameterDictionary; Dictionary <string, object> MatchDict = new Dictionary <string, object>(); //ignore case foreach (var pd in actionDescriptor.GetParameters()) { string key = pd.ParameterName.ToLower(); if (parameterDictionary.ContainsKey(key)) { MatchDict.Add(pd.ParameterName, parameterDictionary[key]); } } return(MatchDict); } return(base.GetParameterValues(controllerContext, actionDescriptor)); }
protected override ActionResult CreateActionResult(ControllerContext controllerContext, ActionDescriptor actionDescriptor, object actionReturnValue) { ThriftActionResult context = ThriftActionResult.GetThriftResult(controllerContext.HttpContext); //check if current request is thrift if (context != null && context.ProcessResult != null) { context.Result = actionReturnValue; return(context); } //默认使用JSON return(new JsonResult() { ContentType = "application/json", ContentEncoding = System.Text.Encoding.UTF8, Data = actionReturnValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); //return base.CreateActionResult(controllerContext, actionDescriptor, actionReturnValue); }