winform提供webapi服务,实现双向http通信

上传者: iml6yu | 上传时间: 2024-05-31 09:02:03 | 文件大小: 10.76MB | 文件类型: ZIP
@[TOP](Winform程序开启Web服务) # 背景 在很久以前为了满足需求,已经开发了一款winform程序,并且是4.6.1版本的,如今为了和第三方对接,需要在这个winform上提供WebAPI的接口。因为第三方的程序是一份没有源码的程序。 # 思路 ## 方法1 - 网上有很多自写web服务的功能,个人觉得过于麻烦,而且还要考虑一些路由规则什么的,太难了 ## 方法2 - 使用iis或者nginx提供服务,一个web程序和一个winform程序实现通信,需要做两个程序,还要交互,麻烦 ## 方法3(本文使用的方法) 考虑4.6.1 版本刚好支持了netcore,所以可以将kestrel服务集成到winform中,直接提供webapi服务 # 实现 ## 在winform程序中引入几个nuget包 Microsoft.AspNetCore Version="2.1.7" Microsoft.AspNetCore.Mvc Version="2.1.3" 在使用nuget引入的时候会将关联的全部引入进来,完整的packages.config文件如下

文件下载

资源详情

[{"title":"( 335 个子文件 10.76MB ) winform提供webapi服务,实现双向http通信","children":[{"title":"测试一个winform.csproj.AssemblyReference.cache <span style='color:#111;'> 265.65KB </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferencesInput.cache <span style='color:#111;'> 42.89KB </span>","children":null,"spread":false},{"title":"DesignTimeResolveAssemblyReferences.cache <span style='color:#111;'> 2.07KB </span>","children":null,"spread":false},{"title":"测试一个winform.csproj.GenerateResource.cache <span style='color:#111;'> 126B </span>","children":null,"spread":false},{"title":"测试一个winform.csproj.CoreCompileInputs.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"测试一个winform.csproj.SuggestedBindingRedirects.cache <span style='color:#111;'> 42B </span>","children":null,"spread":false},{"title":"测试一个winform.exe.config <span style='color:#111;'> 20.99KB </span>","children":null,"spread":false},{"title":"测试一个winform.exe.config <span style='color:#111;'> 20.99KB </span>","children":null,"spread":false},{"title":"packages.config <span style='color:#111;'> 13.83KB </span>","children":null,"spread":false},{"title":"App.config <span style='color:#111;'> 5.22KB </span>","children":null,"spread":false},{"title":"测试一个winform.csproj.CopyComplete <span style='color:#111;'> 0B </span>","children":null,"spread":false},{"title":"Resources.Designer.cs <span style='color:#111;'> 2.80KB </span>","children":null,"spread":false},{"title":"Form1.Designer.cs <span style='color:#111;'> 1.98KB </span>","children":null,"spread":false},{"title":"StartUp.cs <span style='color:#111;'> 1.40KB </span>","children":null,"spread":false},{"title":"AssemblyInfo.cs <span style='color:#111;'> 1.30KB </span>","children":null,"spread":false},{"title":"ValuesController.cs <span style='color:#111;'> 1.10KB </span>","children":null,"spread":false},{"title":"Settings.Designer.cs <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false},{"title":"Program.cs <span style='color:#111;'> 1.02KB </span>","children":null,"spread":false},{"title":"Form1.cs <span style='color:#111;'> 726B </span>","children":null,"spread":false},{"title":".NETFramework,Version=v4.6.1.AssemblyAttributes.cs <span style='color:#111;'> 214B </span>","children":null,"spread":false},{"title":"测试一个winform.csproj <span style='color:#111;'> 47.77KB </span>","children":null,"spread":false},{"title":"Microsoft.CodeAnalysis.CSharp.dll <span style='color:#111;'> 4.46MB </span>","children":null,"spread":false},{"title":"Microsoft.CodeAnalysis.dll <span style='color:#111;'> 2.30MB </span>","children":null,"spread":false},{"title":"Microsoft.DiaSymReader.Native.amd64.dll <span style='color:#111;'> 1.43MB </span>","children":null,"spread":false},{"title":"Microsoft.DiaSymReader.Native.x86.dll <span style='color:#111;'> 1.13MB </span>","children":null,"spread":false},{"title":"System.Text.Encoding.CodePages.dll <span style='color:#111;'> 748.90KB </span>","children":null,"spread":false},{"title":"Newtonsoft.Json.dll <span style='color:#111;'> 647.00KB </span>","children":null,"spread":false},{"title":"System.Reflection.Metadata.dll <span style='color:#111;'> 562.64KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.Core.dll <span style='color:#111;'> 556.08KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Razor.Language.dll <span style='color:#111;'> 458.49KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Server.Kestrel.Core.dll <span style='color:#111;'> 423.88KB </span>","children":null,"spread":false},{"title":"System.Collections.Immutable.dll <span style='color:#111;'> 295.13KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.ViewFeatures.dll <span style='color:#111;'> 282.08KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Diagnostics.dll <span style='color:#111;'> 234.99KB </span>","children":null,"spread":false},{"title":"System.Net.Http.dll <span style='color:#111;'> 193.82KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.RazorPages.dll <span style='color:#111;'> 171.58KB </span>","children":null,"spread":false},{"title":"System.Data.Common.dll <span style='color:#111;'> 150.83KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.DataProtection.dll <span style='color:#111;'> 149.49KB </span>","children":null,"spread":false},{"title":"System.Memory.dll <span style='color:#111;'> 145.23KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.Razor.dll <span style='color:#111;'> 141.58KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Hosting.dll <span style='color:#111;'> 130.49KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.TagHelpers.dll <span style='color:#111;'> 123.58KB </span>","children":null,"spread":false},{"title":"System.Numerics.Vectors.dll <span style='color:#111;'> 113.14KB </span>","children":null,"spread":false},{"title":"System.IO.Compression.dll <span style='color:#111;'> 108.34KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Routing.dll <span style='color:#111;'> 105.49KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.Abstractions.dll <span style='color:#111;'> 98.58KB </span>","children":null,"spread":false},{"title":"netstandard.dll <span style='color:#111;'> 96.30KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Server.IISIntegration.dll <span style='color:#111;'> 93.87KB </span>","children":null,"spread":false},{"title":"Newtonsoft.Json.Bson.dll <span style='color:#111;'> 88.00KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.Razor.Extensions.dll <span style='color:#111;'> 86.02KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Http.dll <span style='color:#111;'> 79.99KB </span>","children":null,"spread":false},{"title":"System.ValueTuple.dll <span style='color:#111;'> 77.32KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Http.Abstractions.dll <span style='color:#111;'> 73.99KB </span>","children":null,"spread":false},{"title":"Microsoft.Net.Http.Headers.dll <span style='color:#111;'> 72.99KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.WebUtilities.dll <span style='color:#111;'> 64.49KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.DependencyModel.dll <span style='color:#111;'> 61.46KB </span>","children":null,"spread":false},{"title":"System.Text.Encodings.Web.dll <span style='color:#111;'> 59.64KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.DependencyInjection.dll <span style='color:#111;'> 58.99KB </span>","children":null,"spread":false},{"title":"System.Diagnostics.DiagnosticSource.dll <span style='color:#111;'> 57.05KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Antiforgery.dll <span style='color:#111;'> 52.99KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.JsonPatch.dll <span style='color:#111;'> 50.99KB </span>","children":null,"spread":false},{"title":"System.IO.Pipelines.dll <span style='color:#111;'> 47.23KB </span>","children":null,"spread":false},{"title":"System.Security.Cryptography.Xml.dll <span style='color:#111;'> 47.14KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.Logging.Abstractions.dll <span style='color:#111;'> 46.52KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.DataAnnotations.dll <span style='color:#111;'> 46.08KB </span>","children":null,"spread":false},{"title":"Microsoft.CodeAnalysis.Razor.dll <span style='color:#111;'> 45.99KB </span>","children":null,"spread":false},{"title":"System.Security.Cryptography.Algorithms.dll <span style='color:#111;'> 45.91KB </span>","children":null,"spread":false},{"title":"System.ComponentModel.Annotations.dll <span style='color:#111;'> 42.14KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll <span style='color:#111;'> 40.38KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.ApiExplorer.dll <span style='color:#111;'> 40.08KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Cryptography.Internal.dll <span style='color:#111;'> 39.99KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.Options.dll <span style='color:#111;'> 39.49KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Authorization.dll <span style='color:#111;'> 38.99KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.FileSystemGlobbing.dll <span style='color:#111;'> 38.49KB </span>","children":null,"spread":false},{"title":"System.Security.AccessControl.dll <span style='color:#111;'> 38.13KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Http.Extensions.dll <span style='color:#111;'> 37.98KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.Formatters.Json.dll <span style='color:#111;'> 37.58KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Routing.Abstractions.dll <span style='color:#111;'> 36.99KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Authentication.Core.dll <span style='color:#111;'> 36.99KB </span>","children":null,"spread":false},{"title":"System.Threading.Overlapped.dll <span style='color:#111;'> 36.87KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.DependencyInjection.Abstractions.dll <span style='color:#111;'> 35.99KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Cors.dll <span style='color:#111;'> 35.48KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.Primitives.dll <span style='color:#111;'> 34.99KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll <span style='color:#111;'> 34.38KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Connections.Abstractions.dll <span style='color:#111;'> 33.38KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Razor.dll <span style='color:#111;'> 32.99KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.Logging.Console.dll <span style='color:#111;'> 32.49KB </span>","children":null,"spread":false},{"title":"System.Threading.Tasks.Extensions.dll <span style='color:#111;'> 32.14KB </span>","children":null,"spread":false},{"title":"System.Security.Permissions.dll <span style='color:#111;'> 32.14KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Mvc.Localization.dll <span style='color:#111;'> 31.58KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Http.Features.dll <span style='color:#111;'> 31.49KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.Caching.Memory.dll <span style='color:#111;'> 31.49KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Razor.Runtime.dll <span style='color:#111;'> 31.48KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.FileProviders.Physical.dll <span style='color:#111;'> 30.99KB </span>","children":null,"spread":false},{"title":"Microsoft.Extensions.Logging.dll <span style='color:#111;'> 30.99KB </span>","children":null,"spread":false},{"title":"System.Diagnostics.Tracing.dll <span style='color:#111;'> 30.87KB </span>","children":null,"spread":false},{"title":"Microsoft.Win32.Registry.dll <span style='color:#111;'> 30.64KB </span>","children":null,"spread":false},{"title":"System.Net.Sockets.dll <span style='color:#111;'> 29.83KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.HttpOverrides.dll <span style='color:#111;'> 29.49KB </span>","children":null,"spread":false},{"title":"Microsoft.AspNetCore.Localization.dll <span style='color:#111;'> 29.49KB </span>","children":null,"spread":false},{"title":"......","children":null,"spread":false},{"title":"<span style='color:steelblue;'>文件过多,未全部展示</span>","children":null,"spread":false}],"spread":true}]

评论信息

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明