如何在Kestrel中的hostingdotnet core 2.0应用程序中定义自定义URL

时间:2017-12-29 15:22:55

标签: kestrel-http-server .net-core-2.0

我使用DotNet Core 2.0托管我的角度应用程序,这是我在program.cs中的托管配置

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using System.Net;

namespace Samples.Web
{
    public class Program
    {
        public static void Main(string[] args)
        {
            BuildWebHost(args).Run();
        }

        public static IWebHost BuildWebHost(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
                .UseKestrel(options=>{
                     options.Listen(IPAddress.Loopback,5050);
                })
                .UseContentRoot(Directory.GetCurrentDirectory())
                .UseIISIntegration()
                .Build();
    }
}

我使用选项覆盖了Kestrel的默认端口号5000.So http://localhost:5050正在运行,但我如何才能使http://localhost:5050/samples之类的自定义主机网址正常工作?

我尝试了无效的UseUrls 。谢谢你的帮助。

0 个答案:

没有答案