1、首先安装一个Kestrel服务器包

Microsoft.AspNetCore.Server.Kestrel

2、在Main方法中插入如下代码

static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); var host = new WebHostBuilder()
.UseKestrel()
.Configure(ConfigureWebApp)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseUrls("http://*:5001").Build();
host.Run();

Application.Run(new Form1());
} private static void ConfigureWebApp(IApplicationBuilder app)
{
app.Run(Request);
} private static async Task Request(HttpContext context)
{
// 处理非静态请求
var request = context.Request;
var response = context.Response;
string path = request.Path.Value;
response.ContentType = "application/json; charset=UTF-8";
bool hasRun = true;
if (path == "/report")
{
string value = request.Query["value"];
response.StatusCode = 200;
}
else
{
response.StatusCode = 404;
}
} }

3、启动窗体  在浏览器输入http://127.0.0.1:5001/report 即可调用 Request 方法中对应的逻辑

最新文章

  1. 基于HTML5 Canvas 实现矢量工控风机叶轮旋转
  2. 《开源大数据分析引擎Impala实战》目录
  3. first Automation
  4. [LintCode] Kth Smallest Number in Sorted Matrix 有序矩阵中第K小的数字
  5. Apache shiro之权限校验流程
  6. jsp导出Excel功能的实现
  7. 代码编译方式 ant +ivy
  8. 如何查看 Apache 的版本
  9. 信息收集-&gt;DNS分析-&gt;dnsdict6
  10. poj3086---数论
  11. 快速构建Windows 8风格应用29-捕获图片与视频
  12. request和response对象的具体介绍
  13. struts2框架的登录制作
  14. 日志的艺术(The art of logging)
  15. UNIX网络编程——Socket通信原理和实践
  16. Spring,@Controller,@RequestMapping, @ResponseBody,@RequestParam
  17. jQuery内容过滤选择器与子元素过滤选择器用法实例分析
  18. bzoj1030 文本生成器
  19. Ubuntu14下nginx服务器链接PHP
  20. Spring Cloud(Dalston.SR5)--Zuul 网关-路由配置

热门文章

  1. [cocos2d-x]关于坐标系
  2. Curve 文件存储在 Elasticsearch 冷热数据存储中的应用实践
  3. 洛谷P1048 典型01背包问题
  4. 如何通过Java应用程序将 PDF转为Word文档
  5. Angularjs的重要概念
  6. python命令行参数argparse常用命令
  7. day15-声明式事务
  8. MySQL优化六,锁
  9. thinkphp无法访问man.php/index/login
  10. Sundial(一)