随笔分类 -  .net / .NET WebApi

摘要:[HttpGet] public void Info() { //获取到token var token = HttpContext.Request.Headers["Authorization"].FirstOrDefault()?.Split(" ").Last(); //解析token信息 va 阅读全文
posted @ 2024-09-27 16:51 龙卷风吹毁停车场 阅读(99) 评论(0) 推荐(0) 编辑
摘要:using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using System.Collections.Generic; [ApiController] [Route("[controller]")] publi 阅读全文
posted @ 2024-09-24 13:38 龙卷风吹毁停车场 阅读(104) 评论(0) 推荐(0) 编辑
摘要:举例: A,B类 public class A { public int id {get;set;} public string name {get;set;} public string phone {get;set;} } public class B { public int age {get 阅读全文
posted @ 2024-09-23 17:49 龙卷风吹毁停车场 阅读(19) 评论(0) 推荐(0) 编辑
摘要:builder.Services.AddSwaggerGen(option => { typeof(ApiVersion).GetEnumNames().ToList().ForEach(version => { option.SwaggerDoc(version, new OpenApiInfo( 阅读全文
posted @ 2024-09-08 21:24 龙卷风吹毁停车场 阅读(10) 评论(0) 推荐(0) 编辑
摘要:[FromRoute(Name="名字")],捕捉的值会被自动赋值给Action中同名的参数;如果名字不一致,可以用[FromRoute(Name="名字")] //前端传入export async function workOrderWithdrawApprove() { return reque 阅读全文
posted @ 2024-08-30 09:55 龙卷风吹毁停车场 阅读(70) 评论(0) 推荐(0) 编辑
摘要:1.第一步,在启动文件添加 builder.Services.AddHttpClient(); 实体类: public class SearchReq { public string Name { get; set; } public string Description { get; set; } 阅读全文
posted @ 2024-08-06 16:16 龙卷风吹毁停车场 阅读(41) 评论(0) 推荐(0) 编辑
摘要:1.第一步: 在启动文件中加入 builder.Services.AddHttpClient(); 2. 第二步: using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using System.Net.Http; name 阅读全文
posted @ 2024-08-06 15:55 龙卷风吹毁停车场 阅读(12) 评论(0) 推荐(0) 编辑
摘要:1.安装nuget SkiaSharp2.创建 VerifyCodeHelper帮助类 using SkiaSharp; namespace WebApplication3 { public class VerifyCodeHelper { /// <summary> /// 获取图像数字验证码 / 阅读全文
posted @ 2024-06-26 18:49 龙卷风吹毁停车场 阅读(44) 评论(0) 推荐(0) 编辑
摘要:1. 再Program.cs 文件中添加 builder.Services.AddSwaggerGen(options => { //读取根据api生成的控制器xml文件 var file = Path.Combine(AppContext.BaseDirectory, "WebApplicatio 阅读全文
posted @ 2024-06-02 19:41 龙卷风吹毁停车场 阅读(34) 评论(0) 推荐(0) 编辑
摘要:1. 创建一个Config文件夹,再文件夹下创建一个类,我这点取名 DefaultValue.cs using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen 阅读全文
posted @ 2024-05-31 22:47 龙卷风吹毁停车场 阅读(399) 评论(0) 推荐(0) 编辑
摘要:设置统一时间返回格式跳转到这片文章: https://www.cnblogs.com/tlfe/p/18225339 阅读全文
posted @ 2024-05-31 22:10 龙卷风吹毁停车场 阅读(11) 评论(0) 推荐(0) 编辑
摘要:安装 nuget:Microsoft.AspNetCore.Mvc.NewtonsoftJsonModel文件下创建的基类: namespace WebApiTest1.Model { public class Class { public long Id { get; set; } public 阅读全文
posted @ 2024-05-31 22:00 龙卷风吹毁停车场 阅读(103) 评论(0) 推荐(0) 编辑
摘要:创建新项目,选择创建 webapi项目 1. 创建完成后点击 Controllers 文件夹,单机右键,选择添加控制器 2.点击确定3.选择api控制器 4.点击确定 5. 更具自己需求,修改 [Route("api/[controller]")], 我这点改为 [Route("api/[contr 阅读全文
posted @ 2024-05-24 14:55 龙卷风吹毁停车场 阅读(147) 评论(0) 推荐(0) 编辑
摘要:我在appsettings.json中配置了链接数据库的信息,红色标记区域 { "ConnectionStrings": { "connStr": "server=.;database=PerformanceAppraisalDb;uid=sa;pwd=123456" }, "Logging": { 阅读全文
posted @ 2024-05-24 13:56 龙卷风吹毁停车场 阅读(99) 评论(0) 推荐(0) 编辑
摘要:1. 再Program.cs 文件中添加 using WebApplication1.Webapi.Utility.ApiVersions; var builder = WebApplication.CreateBuilder(args); // Add services to the contai 阅读全文
posted @ 2024-05-24 11:54 龙卷风吹毁停车场 阅读(37) 评论(0) 推荐(0) 编辑
摘要:1.打开 Program.cs 文件,在 var app = builder.Build(); 语句前添加如下代码 builder.Services.AddCors(o => o.AddPolicy("any", p => p.AllowAnyOrigin().AllowAnyHeader().Al 阅读全文
posted @ 2024-05-22 09:12 龙卷风吹毁停车场 阅读(72) 评论(0) 推荐(0) 编辑

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