I added a line .UseUrls("http://*:5000")so that clients from other hosts access the web api.
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls("http://*:5000")
.Build();
host.Run();
}
However, using a browser to access localhost:5000/api/Testreceived an error HTTP/1.1 400 Bad Request? Should it .UseUrls()only compile for production?
HTTP / 1.1 400 Bad Request
Date: Mon, 08 Aug 2016 21:42:30 GMT
Content-Length: 0
Server: kestrel
During testing, they are copied from the Visual Studio output window during testing.
Microsoft.AspNetCore.Hosting.Internal.WebHost: info: HTTP / 1.1 start request GET http: // localhost: 5000 / api / Test
Microsoft.AspNetCore.Server.IISIntegration.IISMiddleware: : "MS-ASPNETCORE-TOKEN" "9bca37f2-7eda-4517-9f8f-60b6cc05cf01", .
Microsoft.AspNetCore.Hosting.Internal.WebHost: : 8.5976ms 400