前言

ParaModelValidateAttribute(参数校验)ErrorCatch(错误捕捉)为例。

在方法上添加(局部)

这种方式比较灵活

    [ParaModelValidate]
[ErrorCatch]
public class BaseController : ControllerBase
{
public ContentResult JsonResult(dynamic data = null)
{
ContentResult result = JsonContentResultBuilder.BuildViewJsonResult(data); return result;
}
}

在Startup中添加(全局)

这种方式应用于所有方法

        public void ConfigureServices(IServiceCollection services)
{
services.AddControllers(); services.AddControllersWithViews().AddNewtonsoftJson(); #region 配置过滤器 services.AddControllersWithViews(options => {
options.Filters.Add(typeof(ParaModelValidateAttribute));
}); services.AddControllersWithViews(options => {
options.Filters.Add(typeof(ErrorCatchAttribute));
}); #endregion }

最新文章

  1. Trace Flag
  2. ssh的原理和流程
  3. android 调用地图
  4. HttpClient请求返回JSON、图片
  5. [JS3] 立即执行JS
  6. Code First Migrations更新数据库结构的具体步骤
  7. 【oracle】数据库、表空间、用户、数据表之间的关系
  8. 利用改进的cca算法,进行识别
  9. POJ - 1422 Air Raid 二分图最大匹配
  10. NeuChar 平台使用及开发教程(三):使用 NeuChar 的菜单服务
  11. Python全栈开发记录_第四篇(集合、函数等知识点)
  12. mongodb的db.collection is not function
  13. c# 字典
  14. 738. Monotone Increasing Digits 单调递增的最接近数字
  15. 理解Java枚举类型
  16. case关联表查询
  17. 监控Tomcat
  18. 发布上线前,先小秀一把俺的64位浏览器,速度那觉对是杠杠滴,上youtube,上google不费劲
  19. 11 python shutil 模块
  20. Linux内核中断处理机制

热门文章

  1. iOS 自定义tabBarController(中间弧形)
  2. Flutter ListTile - Flutter每周一组件
  3. C# 生成6位短信验证码
  4. Nginx 配置日志路径(nginx.conf没有写log路径,所以debug的时候找不到日志)
  5. 由两个问题引发的对GaussDB(DWS)负载均衡的思考
  6. Linux腾讯云下安装mysql
  7. 3. Longest Substring Without Repeating Characters寻找不重复的最大子串
  8. 基于Opencv的简单图像处理
  9. 栈面板类StackPane?
  10. Java学习日报7.19