Кестрел Настройки - PullRequest
0 голосов
/ 23 июня 2019

Я не могу запустить свой веб-сайт при попытке настроить Kestrel с помощью промежуточного программного обеспечения UseKestrel в ASP.NET Core 2.2 (работает на Windows 10).

public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
    return new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .ConfigureAppConfiguration((hostingContext, config) =>
        {
            var env = hostingContext.HostingEnvironment;
            config.SetBasePath(env.ContentRootPath);
            config.AddInMemoryCollection(new[]
                   {
                             new KeyValuePair<string,string>("the-key", "the-value")
                   })
                   .AddJsonFile("appsettings.json", reloadOnChange: true, optional: false)
                   .AddJsonFile($"appsettings.{env}.json", optional: true)
                   .AddEnvironmentVariables();
        })
        .ConfigureLogging((hostingContext, logging) =>
        {
            logging.AddDebug();
            logging.AddConsole();
        })
        .UseIISIntegration()
        .UseDefaultServiceProvider((context, options) =>
        {
            options.ValidateScopes = context.HostingEnvironment.IsDevelopment();
        })
        .UseStartup<Startup>();
}

Я не получилошибка, но мой сайт не загружается.

1 Ответ

0 голосов
/ 24 июня 2019

Можете ли вы попробовать это и посмотреть, что произойдет -

        public static void Main(string[] args)
        {
            CreateWebHostBuilder(args).Build().Run();
        }

        public static IWebHostBuilder CreateWebHostBuilder(string[] args)
        {
            return WebHost.CreateDefaultBuilder(args)                    
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseKestrel(options =>
              {
                  options.Listen(IPAddress.Parse(0.0.0.0), Convert.ToInt32(5000));
              })
                .UseUrls("0.0.0.0:5000")
                .UseStartup<Startup>();
        }
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...