1,抛弃try - catch, 使用UserFriendlyException抛出友好异常
a)在Shared项目的ErrorCode对象中,自定义常量 public const string EssayCreateErrorCode = "-1";
b)API中测试抛出异常:throw new UserFriendlyException("测试状态码错误", HelloKeepDomainErrorCodes.EssayCreateErrorCode);
这里还可以定义更多的details,data等数据
c)正常情况下将抛出403,为了习惯,我们将这个状态码的返回都改为200,只需要在HttpApi项目的ConfigureServices方法中,添加 Configure<AbpExceptionHttpStatusCodeOptions>(options => { options.Map(HelloKeepDomainErrorCodes.EssayCreateErrorCode, HttpStatusCode.OK); });

2,默认IdentityUserManager 密码强度调节

网友评论