随笔分类 -  netcore

摘要:后端函数 /// <summary> /// 上传文件 /// </summary> /// <param name="files">文件流</param> /// <returns></returns> [HttpPost] public void FileSave(List < IFormFil 阅读全文
posted @ 2022-09-06 08:59 少年。 阅读(132) 评论(0) 推荐(0) 编辑
摘要:net5配合vue3图片上传 FileSave函数 /// <summary> /// 上传文件 /// </summary> /// <param name="files">文件流</param> /// <returns></returns> [HttpPost] public void Fil 阅读全文
posted @ 2022-02-22 09:24 少年。 阅读(101) 评论(0) 推荐(0) 编辑
摘要:腾讯云安装 Centos8系统 NET环境安装 在安装DotNetCore环境之前需要注册Microsoft Key以及Product Repository,并且还需要安装一些依赖,这一步每台机器只需要运行一次,具体命令如下 sudo rpm -Uvh https://packages.micros 阅读全文
posted @ 2021-08-17 14:11 少年。 阅读(693) 评论(0) 推荐(0) 编辑
摘要:数据库的实体模型和视图模型进行分离 数据库持久化对象(Persistent Object):顾名思义,这个对象是用来将我们的数据持久化到数据库,一般来说,持久化对象中的字段会与数据库中对应的 table 保持一致。 视图对象(View Object):视图对象 VO 是面向前端用户页面的,一般会包含 阅读全文
posted @ 2021-07-30 12:15 少年。 阅读(227) 评论(0) 推荐(0) 编辑
摘要:通过NuGet获取AngleSharp Install-Package AngleSharp 创建AngleSharpController.cs using Microsoft.AspNetCore.Mvc; using Snblog.Service.AngleSharp; using System 阅读全文
posted @ 2021-07-08 13:46 少年。 阅读(146) 评论(0) 推荐(0) 编辑
摘要:# netCore使用依赖注入 依赖注入是一种常用的设计模式,用于解耦组件之间的依赖关系。通过依赖注入,我们可以将一个组件所依赖的其他组件的创建和管理工作交给容器来完成,从而实现组件之间的解耦和灵活性 .NET Core提供了内置的依赖注入容器,使我们能够轻松地实现依赖注入。下面是使用依赖注入的步骤 阅读全文
posted @ 2021-04-12 14:08 少年。 阅读(420) 评论(0) 推荐(0) 编辑
摘要:nuget dotnet add package Serilog.AspNetCore 配置Program.cs using System; using System.Collections.Generic; using System.IO; using System.Linq; using Sys 阅读全文
posted @ 2021-04-07 11:16 少年。 阅读(284) 评论(0) 推荐(0) 编辑
摘要:nugt包依赖 1.Microsoft.Extensions.Caching.Abstractions 2.Microsoft.Extensions.Caching.Memory 封装帮助类 添加类库Snblog.Cache 新建文件 Cache 新建帮助类 CacheManager.cs usin 阅读全文
posted @ 2021-04-06 14:28 少年。 阅读(515) 评论(0) 推荐(1) 编辑
摘要:分析器包会通知你执行以下操作的任何控制器操作: 返回未声明的状态代码。 返回未声明的成功结果。 记录不返回的状态代码。 包含显式模型验证检查。 引用分析器包 在项目文件中包含 IncludeOpenAPIAnalyzers 属性: <PropertyGroup> <IncludeOpenAPIAna 阅读全文
posted @ 2021-04-06 14:15 少年。 阅读(116) 评论(0) 推荐(0) 编辑
摘要:# netCore中Swagger版本控制 ### 添加枚举类型 定义版本号 ```c# /// /// 版本控制 /// public enum ApiVersion { /// /// v1版本 /// V1 = 1, /// /// v2版本 /// V2 = 2 } ``` ### 注册服务 阅读全文
posted @ 2021-04-05 14:18 少年。 阅读(303) 评论(0) 推荐(0) 编辑
摘要:安装Nuget Install-Package MiniProfiler.AspNetCore.Mvc startup.cs #region MiniProfiler services.AddMiniProfiler(options => options.RouteBasePath = "/prof 阅读全文
posted @ 2021-03-29 16:38 少年。 阅读(462) 评论(0) 推荐(0) 编辑
摘要:nuget安装 Microsoft.AspNetCore.Authentication.JwtBearer 3.1.0 版本 appsettings.json "Authentication": { //jwt "JwtBearer": { "IsEnabled": "true", "Securit 阅读全文
posted @ 2021-02-26 13:39 少年。 阅读(827) 评论(0) 推荐(0) 编辑
摘要:跨域问题的出现,简而言之就是基于浏览器同源策略而反馈出来的一种安全机制,是前端开发调用中出现的一种十分常见的问题,且解决方法有多种,比如采用Nginx做代理服务器,或者在前端使用自己的代理服务器,或者是直接在后端设置允许跨域,这里采用的是最后一种解决手段。 Startup Startup类里先定义一 阅读全文
posted @ 2020-05-13 13:50 少年。 阅读(833) 评论(0) 推荐(0) 编辑
摘要:# netCore封装efcore仓储模式 参考:[三层框架项目搭建教程](https://www.cnblogs.com/han1982/p/11058788.html) ### 安装依赖包 ```ruby Install-Package MySql.Data.EntityFrameworkCor 阅读全文
posted @ 2020-05-08 15:45 少年。 阅读(2338) 评论(1) 推荐(2) 编辑
摘要:# WebAPI约定 约定在控制器生成前运行,可以修改默认的约定,如可以向控制器统一添加路由前缀 ## 默认约定 集将应用于 ContactsConventionController 中的所有操作: ```c# [ApiController] [ApiConventionType(typeof(De 阅读全文
posted @ 2020-04-29 13:48 少年。 阅读(504) 评论(0) 推荐(0) 编辑
摘要:引入Pomelo.EntityFrameworkCore.MySql程序包 ConfigureServices // other service configurations go here // replace "YourDbContext" with the class name of your 阅读全文
posted @ 2020-03-20 15:28 少年。 阅读(5331) 评论(0) 推荐(0) 编辑
摘要:安装 先下载.net core 3.1的SDK(开发.net core项目时会用到)和Runtime(用来运行.net core的应用程序) 地址:https://dotnet.microsoft.com/download/visual-studio-sdks?utm_source=getdotne 阅读全文
posted @ 2020-03-20 15:26 少年。 阅读(430) 评论(0) 推荐(0) 编辑
摘要:原文:net core 3.1 跨域 Cors 找不到 “Access-Control-Allow-Origin” ConfigureServices public void ConfigureServices(IServiceCollection services) { services.AddC 阅读全文
posted @ 2020-03-20 15:21 少年。 阅读(855) 评论(0) 推荐(1) 编辑
摘要:配置中间件 将 Swagger 生成器添加到 Startup.ConfigureServices 方法中的 服务集合中: ConfigureServices //注册Swagger生成器,定义一个和多个Swagger 文档 services.AddSwaggerGen(c => { c.Swagge 阅读全文
posted @ 2020-03-19 17:15 少年。 阅读(458) 评论(0) 推荐(0) 编辑
摘要:netcore3.1使用Jwt 认证授权区别 (Authentication)和授权(Authorization)的区别,以免混淆了。认证是确认的过程中你是谁,而授权围绕是你被允许做什么,即权限。显然,在确认允许用户做什么之前,你需要知道他们是谁,因此,在需要授权时,还必须以某种方式对用户进行身份验 阅读全文
posted @ 2020-03-10 17:56 少年。 阅读(1195) 评论(2) 推荐(0) 编辑

点击右上角即可分享
微信分享提示