private string BuildResult(int errorNo, string errorInfo) { var ret = new ResultInfo() { Error_no = errorNo, Error_info = errorInfo }; var resp = JsonHelper.Serialize(ret); var encryptSrc = TripleDESCryptogram.Encrypt(resp); return(encryptSrc); }
public override void OnActionExecuted(ActionExecutedContext context) { if (context.Result == null) { base.OnActionExecuted(context); return; } var resultType = context.Result.GetType(); var property = resultType.GetProperty("Value"); if (property == null) { property = resultType.GetProperty("Content"); } if (property == null) { throw new NotSupportedException("表单请求加解密不支持的ActionResult:" + resultType.FullName); } var val = property.GetValue(context.Result); string json = null; if (val.GetType() == typeof(string)) { json = val.ToString(); } else { json = JsonHelper.Serialize(val); } var encryptSrc = TripleDESCryptogram.Encrypt(json); context.Result = new ContentResult() { Content = encryptSrc }; base.OnActionExecuted(context); var interceptor = context.HttpContext.RequestServices.GetService(typeof(IFormEncryptInterceptor)) as IFormEncryptInterceptor; if (interceptor != null) { interceptor.AfterResponse(context); } }