摘要:
Program.cs var corsPolicyName = "_myAllowSpecificOrigins"; builder.Services.AddCors(options => { options.AddPolicy(name: corsPolicyName, builder => { 阅读全文
posted @ 2021-12-09 14:23
PrintY
阅读(1900)
评论(0)
推荐(0)
摘要:
C#中语法,model中属性默认都是大驼峰,但是.NET6 WebAPI默认出传到前台自动转化成小驼峰写法,如果要避免这个问题,处理也比较简单~ Program.cs builder.Services.AddControllers() .AddJsonOptions(options => { opt 阅读全文
posted @ 2021-12-09 14:21
PrintY
阅读(977)
评论(1)
推荐(0)
摘要:
Program.cs文件中 //获取IP使用 builder.Services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>(); Controller中 private readonly IHttpContextAccessor h 阅读全文
posted @ 2021-12-09 14:15
PrintY
阅读(788)
评论(0)
推荐(0)
摘要:
1、安装依赖 Microsoft.Extensions.Logging.Log4Net.AspNetCore 2、配置文件 <?xml version="1.0" encoding="utf-8" ?> <configuration> <!-- This section contains the l 阅读全文
posted @ 2021-12-09 14:11
PrintY
阅读(792)
评论(0)
推荐(0)
摘要:
1、上代码 /// <summary> /// API白名单过滤器 /// </summary> public class APIFilter : ActionFilterAttribute { /// <summary> /// 控制器中加了该属性的方法中代码执行之前该方法。 /// 所以可以用做 阅读全文
posted @ 2021-12-09 14:03
PrintY
阅读(862)
评论(0)
推荐(0)

浙公网安备 33010602011771号