0

I am hosting my angular application using DotNet Core 2.0 and here is my hosting configuration in 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();
    }
}

I overrided default port number 5000 of Kestrel using options.So http://localhost:5050 is working but how can I make a custom host url something like http://localhost:5050/samples working as well?

I tried UseUrls which didn't work. Thanks for help.

user3154990
  • 555
  • 4
  • 13
  • 27
  • For that you need routing. Have a look at [Routing Asp.net core](https://learn.microsoft.com/de-de/aspnet/core/fundamentals/routing) – pr177 Dec 31 '17 at 11:41
  • This is angular application, the first default route will be app. – user3154990 Jan 02 '18 at 13:54
  • However you have the Startup class where you can define the routing in the Configure method. – pr177 Jan 02 '18 at 14:21

0 Answers0