zoukankan      html  css  js  c++  java
  • 单文件版本的netframework的net core 2.1

    如果你还在用net4.5,如果你还在用netframework,又想使用netcore2.1的库或者功能,又觉得nuget动不动就好大,可以试试下面的这个。

    https://pan.baidu.com/s/1uxywusd485RgqxSnuVTzQw

    就一个dll,里面netcore新增的功能,比如span,比如新的非winhttp.dll的httpclient,都可以用

    例:

    创建一个新的console netframework4.5的项目

    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Logging;
    using Microsoft.AspNetCore.Http;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Microsoft.AspNetCore.Server.Kestrel.Core;
    using Microsoft.AspNetCore.Server.Kestrel.Core.Internal;
    using Microsoft.Extensions.Options;
    using Microsoft.AspNetCore;

    namespace testhttp
    {
    class Program
    {
    static void Main(string[] args)
    {
    Http();
    }

    static void Http()
    {
    var host = new WebHostBuilder()
    .UseKestrel(options =>
    {
    // options.ThreadCount = 4;
    //options.NoDelay = true;
    //options.UseConnectionLogging();
    })
    .UseUrls("http://127.0.0.1:5001")
    .UseContentRoot(Directory.GetCurrentDirectory())
    .UseStartup<Startup>()
    .Build();
    host.Run();
    }
    }

    public class Startup
    {
    public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
    {
    loggerFactory.AddConsole(LogLevel.Trace);

    app.Run(async context =>
    {
    Console.WriteLine("{0} {1}{2}{3}",
    context.Request.Method,
    context.Request.PathBase,
    context.Request.Path,
    context.Request.QueryString);
    Console.WriteLine("Method:{0}", context.Request.Method);
    Console.WriteLine("PathBase:{0}", context.Request.PathBase);
    Console.WriteLine("Path:{0}", context.Request.Path);
    Console.WriteLine("QueryString:{0}", context.Request.QueryString);

    var connectionFeature = context.Connection;
    Console.WriteLine("Peer:{0}", connectionFeature.RemoteIpAddress.ToString());
    Console.WriteLine("Sock:{0}", connectionFeature.LocalIpAddress.ToString());

    context.Response.ContentLength = 11;
    context.Response.ContentType = "text/plain";
    await context.Response.WriteAsync("Hello world");
    });
    }
    }
    }

    这样就可以了,对了libuv你自己下一个,丢到输出目录 ,或者用这个nuget

    https://www.nuget.org/packages/Libuv/

  • 相关阅读:
    FineBI与power BI,一个是国外风生水起的微软巨头,一个是方兴未艾的国产BI厂商领导者
    Linux下的crontab定时执行任务命令详解举例
    手把手教你搭建SSH框架(Eclipse版)
    一、连接池的定义
    centos安装sftp服务win搭建 sftp 服务器
    前往阿里云的企业优惠活动页面
    世界可能是思想最为混乱的时候,无论你说什么
    python面向对象编程class1
    Python 文件I/O 文件读写模式r,r+,w,w+,a,a+的区别
    Python中的装饰器是你进入Python大门的一道坎,不管你跨不跨过去它都在那里
  • 原文地址:https://www.cnblogs.com/sevencatwang/p/9126034.html
Copyright © 2011-2022 走看看