随笔分类 -  AspNetCore

摘要:1.Nuget包 install-package Microsoft.Extensions.Caching.Memory -project xxxProjectName -version 7.0.0 2.封装类 2.1.ICacheService /// <summary> /// 缓存服务接口 / 阅读全文
posted @ 2025-08-27 14:16 Robot-Blog 阅读(38) 评论(0) 推荐(0)
摘要:1.安装包:IHttpContextAccessor 1.对于ASP.NET Core 项目(如 Web API、MVC):项目默认引用 Microsoft.AspNetCore.App 元包(.NET 6 中自动包含),已涵盖 IHttpContextAccessor 所需的全部依赖,无需手动安装 阅读全文
posted @ 2025-08-26 16:33 Robot-Blog 阅读(29) 评论(0) 推荐(0)
摘要:背景 多台服务器时间没有自动同步或延迟,颁发令牌服务器的时间 比 鉴权令牌服务器时间 晚,导致jwt解密失败 netframework & jwt 8.2.3 using JWT; using JWT.Algorithms; using JWT.Builder; using JWT.Exceptio 阅读全文
posted @ 2025-08-22 17:11 Robot-Blog 阅读(27) 评论(0) 推荐(0)
摘要:根据NETCore的注入方式添加三个接口 /// <summary> /// 瞬时注入服务接口 /// </summary> public interface ITransient { } /// <summary> /// 作用域注入服务接口 /// </summary> public inter 阅读全文
posted @ 2024-07-12 16:02 Robot-Blog 阅读(89) 评论(0) 推荐(0)
摘要:文件模板代码 T4_GetEntityDic <#@ template language="C#" #> <#@ output extension=".cs" #> <#@ assembly name="System.Core" #> <#@ import namespace="System.IO" 阅读全文
posted @ 2024-06-18 14:30 Robot-Blog 阅读(71) 评论(0) 推荐(0)
摘要:AuthorizationWithCustMiddleware /// <summary> /// 自定义授权中间件类:使用 身份验证中间件 存储的身份信息来进行权限验证 /// 一定要先启用 身份验证中间件(app.UseAuthentication()),它会验证请求中的身份信息,并将身份信息存 阅读全文
posted @ 2024-05-10 17:30 Robot-Blog 阅读(231) 评论(0) 推荐(0)
摘要:Nuget <PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" /> <PackageReference Include="Hangfire.Dashboard.BasicAuthorization" Version="1. 阅读全文
posted @ 2024-04-22 17:32 Robot-Blog 阅读(415) 评论(0) 推荐(0)
摘要:Nuget <PackageReference Include="NLog.Web.AspNetCore" Version="5.3.8" /> <PackageReference Include="NLog" Version="5.2.8" />install-package NLog -vers 阅读全文
posted @ 2024-03-28 13:44 Robot-Blog 阅读(198) 评论(0) 推荐(0)
摘要:Nuget Runtime: Net6 MailKit 4.2.0 MimeKit 4.2.0 发送纯文本 { var bodyBuilder = new BodyBuilder(); bodyBuilder.TextBody = "这是一封纯文本邮件"; message.Body = bodyBu 阅读全文
posted @ 2023-09-21 15:24 Robot-Blog 阅读(174) 评论(0) 推荐(0)
摘要:JsonSerializerOptions.PropertyNamingPolicy 属性 services.AddControllers().AddJsonOptions(options => { // 获取或设置一个值,该值指定用于将对象的属性名称转换为其他格式(例如 camel 大小写)的策略 阅读全文
posted @ 2023-08-01 09:56 Robot-Blog 阅读(145) 评论(0) 推荐(0)
摘要:错误信息 严重性 代码 说明 项目 文件 行 禁止显示状态 错误 NETSDK1004 找不到资产文件“C:\BaseContract \obj\project.assets.json”。运行 NuGet 包还原以生成此文件。BaseContract C:\Program Files\dotnet\ 阅读全文
posted @ 2023-07-28 13:22 Robot-Blog 阅读(1760) 评论(0) 推荐(0)
摘要:Error A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 阅读全文
posted @ 2023-07-28 10:30 Robot-Blog 阅读(315) 评论(0) 推荐(0)
摘要:1.Startup.ConfigureServices services.AddHttpClient(); 2.构造函数注入 private readonly IHttpClientFactory _clientFactory; public XXX(IHttpClientFactory clien 阅读全文
posted @ 2023-01-17 14:18 Robot-Blog 阅读(322) 评论(0) 推荐(0)
摘要:背景: 参数没有通过校验模型检查时,直接返回错误信息,但是这个错误信息可读性很弱,并不能被前端很方便的使用 { "type": "https://xxx", "title": "One or more validation errors occurred.", "status": 400, "tra 阅读全文
posted @ 2023-01-13 17:22 Robot-Blog 阅读(83) 评论(0) 推荐(0)
摘要:1.Nuget install-package Quartz.Extensions.Hosting 2.添加文件:WhileJob /// <summary> /// while quartz job /// </summary> [DisallowConcurrentExecution] publ 阅读全文
posted @ 2023-01-13 16:22 Robot-Blog 阅读(359) 评论(0) 推荐(0)
摘要:1.版本枚举 /// <summary> /// swagger 多版本枚举 /// </summary> public enum SwaggerVersionEnum { /// <summary> /// V1 版本,复杂情况可通过特性获取 /// </summary> [Description 阅读全文
posted @ 2022-09-23 17:42 Robot-Blog 阅读(318) 评论(0) 推荐(0)
摘要:1.添加Nuget install-package Swashbuckle.AspNetCore -project XXX -version 6.4.0 2.添加静态类扩展方法 2.1.生成项目xml:选中项目 / 右键 / 属性 / 生成 / 输出 / 选中xml文档文件 2.2.system_v 阅读全文
posted @ 2022-09-21 15:56 Robot-Blog 阅读(1113) 评论(0) 推荐(0)
摘要:Session 1.在 Startup: ConfigureServices 中添加一下代码 services.AddSession(); 2.在 Startup: Configure 中添加一下代码 app.UseSession(); 3.正常使用 var sessionKeyName = "S- 阅读全文
posted @ 2021-12-28 17:53 Robot-Blog 阅读(216) 评论(0) 推荐(0)
摘要:1.配置DbContext 1.1.Startup / ConfigureServices services.AddDbContext<CustDbContext>(options => options.UseSqlServer(configuration["ConnectionStrings:De 阅读全文
posted @ 2021-12-08 17:22 Robot-Blog 阅读(255) 评论(0) 推荐(0)
摘要:调用其他类方法报错:Link 引用程序集即可 <#@ assembly name="netstandard" #> 阅读全文
posted @ 2021-12-08 14:05 Robot-Blog 阅读(752) 评论(0) 推荐(0)