zoukankan      html  css  js  c++  java
  • net Core 3.1 发布自定义 端口

    根目录创建 hosting.json

    {
      "urls": "http://*:8081"
    }

    Program.cs 

    public static void Main(string[] args)
     {
                // 生成承载 web 应用程序的 Microsoft.AspNetCore.Hosting.IWebHost。Build是WebHostBuilder最终的目的,将返回一个构造的WebHost,最终生成宿主。
                var host = CreateHostBuilder(args).Build();
    
               // 运行 web 应用程序并阻止调用线程, 直到主机关闭。
                // 创建完 WebHost 之后,便调用它的 Run 方法,而 Run 方法会去调用 WebHost 的 StartAsync 方法
                // 将Initialize方法创建的Application管道传入以供处理消息
                // 执行HostedServiceExecutor.StartAsync方法
                // ※※※※ 有异常,查看 Log 文件夹下的异常日志 ※※※※  
                host.Run();    
      }    
    
    public static IHostBuilder CreateHostBuilder(string[] args) =>
              Host.CreateDefaultBuilder(args)
                .UseServiceProviderFactory(new AutofacServiceProviderFactory()) //<--NOTE THIS
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder
                    .ConfigureKestrel(serverOptions =>
                    {
                        serverOptions.AllowSynchronousIO = true;//启用同步 IO
                    })
              //方式一 .ConfigureAppConfiguration(builder
    => { builder.AddJsonFile("hosting.json", optional: true); }) .UseStartup<Startup>()
    //方式二
    //.UseUrls("http://*:8081") });
  • 相关阅读:
    理解jquery的$.extend()、$.fn和$.fn.extend()
    前端跨域请求原理及实践
    [leetcode]Minimum Path Sum
    [leetcode]Jump Game II
    [leetcode]Merge Intervals
    [leetcode]Length of Last Word
    [leetcode]Unique Paths
    [leetcode]Text Justification
    [leetcode]Binary Tree Level Order Traversal
    [leetcode]Jump Game
  • 原文地址:https://www.cnblogs.com/shuaichao/p/12953116.html
Copyright © 2011-2022 走看看