WebApi返回的ModelResponse对象的Data属性的数据加密或不加密

ModelResponse对象返回的数据进行加密:
C# Code:
ModelResponse result = new ModelResponse();
//返回的数据进行加密写法:
IKeyProvider key = ApiKeyProvider.GetKeyProvider(_UserRequest.ApiKey);
result.Data = JsonConvertEx.ToJson(user, true, true, key);//返回结果,data加密
result.DataIsEncrypted = true;//返回数据是加密的
//来源:C/S框架网 | www.csframework.com | QQ:23404761
//返回的数据进行加密写法:
IKeyProvider key = ApiKeyProvider.GetKeyProvider(_UserRequest.ApiKey);
result.Data = JsonConvertEx.ToJson(user, true, true, key);//返回结果,data加密
result.DataIsEncrypted = true;//返回数据是加密的
//来源:C/S框架网 | www.csframework.com | QQ:23404761
ModelResponse对象返回的数据不加密:
C# Code:
ModelResponse result = new ModelResponse();
//返回的数据不加密写法
result.Data = JsonConvertEx.ToJson(user);//返回结果
result.DataIsEncrypted = false;//返回数据不加密
//来源:C/S框架网 | www.csframework.com | QQ:23404761
//返回的数据不加密写法
result.Data = JsonConvertEx.ToJson(user);//返回结果
result.DataIsEncrypted = false;//返回数据不加密
//来源:C/S框架网 | www.csframework.com | QQ:23404761
注意:若返回的数据是加密的, 客户端必须要解密.Data的数据。
若是Web端,APP端调用WebApi解密,建议返回的数据不加密。


扫一扫加微信


版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网