|
|
|
@ -6,6 +6,7 @@ using Serilog;
|
|
|
|
|
using Serilog.Core;
|
|
|
|
|
using Serilog.Events;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Net;
|
|
|
|
|
|
|
|
|
|
namespace PhotoCollector;
|
|
|
|
|
|
|
|
|
@ -81,9 +82,35 @@ internal static class Program
|
|
|
|
|
webBuilder.UseSetting(WebHostDefaults.DetailedErrorsKey, "true");
|
|
|
|
|
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
|
|
|
|
webBuilder.UseStartup<Startup>();
|
|
|
|
|
webBuilder.UseUrls("http://localhost:8440");
|
|
|
|
|
webBuilder.UseUrls($"http://localhost:{GetDynamicFreePort()}");
|
|
|
|
|
//webBuilder.UseUrls("http://localhost:48440");
|
|
|
|
|
})
|
|
|
|
|
.Build();
|
|
|
|
|
await WebHost.StartAsync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int GetDynamicFreePort()
|
|
|
|
|
{
|
|
|
|
|
var port = 49152;
|
|
|
|
|
while (port < 65535)
|
|
|
|
|
{
|
|
|
|
|
var listener = new HttpListener();
|
|
|
|
|
listener.Prefixes.Add($"http://localhost:{port}/");
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
listener.Start();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
port++;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
listener.Stop();
|
|
|
|
|
listener.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return port;
|
|
|
|
|
}
|
|
|
|
|
}
|