
.NET Core3.1 微服务
2b勿扰
专注技术的研究
展开
-
asp.net core3.1 实战开发(webapi接口文档可视化工具swagger的使用)
首先控制台安装 Swashbuckle.AspNetCore -Version 版本号-rc4包 public void ConfigureServices(IServiceCollection services) { #region apiSettings services.AddSwaggerGen(m => m.SwaggerDoc("v1", new Open...原创 2020-01-18 16:13:44 · 21040 阅读 · 0 评论 -
C#/.NET 微服务专题(JWT的权限认证使用)
JWT客户端的使用安装:Microsoft.AspNetCore.Authentication.JwtBearerpublic void ConfigureServices(IServiceCollection services){ #region jwt校验 services.AddAuthentication(JwtBearerDefaults.Authenticatio...原创 2020-01-17 20:41:45 · 29474 阅读 · 0 评论 -
C#/.NET 微服务专题(ocelot网关的使用)
首先先nuget:ocelot包public void ConfigureServices(IServiceCollection services){ services.AddOcelot().AddConsul().AddPolly();}// This method gets called by the runtime. Use this method to configur...原创 2020-01-16 23:43:23 · 20567 阅读 · 0 评论 -
C#/.NET 微服务专题(consul实现负载均衡)
#region 调用---负载均衡{ //string url = "http://localhost:5726/api/users/get"; //string url = "http://localhost:5727/api/users/get"; //string url = "http://localhost:5728/api/users/get"; st...原创 2020-01-16 23:32:39 · 21467 阅读 · 1 评论 -
C#/.NET 微服务专题(consul注册服务发现的使用)
首先nuget:consul包封装consul注册代码如下/// <summary>/// 自己封装的注册类/// </summary>public static class ConsulHelper{ public static void ConsulRegist(this IConfiguration configuration) { ...原创 2020-01-16 20:08:32 · 31162 阅读 · 0 评论 -
C#/.NET 微服务专题(获取控制台启动的参数配置 )
首先在core3.1 的program的文件中加上如下代码public static void Main(string[] args){ var config = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddCommandLine(args)//支持命令行...原创 2020-01-16 19:15:51 · 19219 阅读 · 0 评论 -
C#/.NET 微服务专题(webapi后端请求的扩展封装 )
public static class WebApiHelperExtend { public static string InvokeApi(string url) { using (HttpClient httpClient = new HttpClient()) { Ht...原创 2020-01-16 19:13:19 · 28292 阅读 · 3 评论 -
C#/.NET 微服务专题(core3.1 webapi的跨域问题 )
core3.1 解决跨域问题代码如下引入 :Microsoft.AspNetCore.Corspublic void Configure(IApplicationBuilder app, IWebHostEnvironment env){ if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); ...原创 2020-01-16 14:05:10 · 27913 阅读 · 1 评论