diff --git a/samples/OpenIdConnectSample/Program.cs b/samples/OpenIdConnectSample/Program.cs index 49cbf139d6..741dd6ebf5 100644 --- a/samples/OpenIdConnectSample/Program.cs +++ b/samples/OpenIdConnectSample/Program.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Net; using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; @@ -13,11 +15,17 @@ namespace OpenIdConnectSample var host = new WebHostBuilder() .UseKestrel(options => { - // Configure SSL - var serverCertificate = LoadCertificate(); - options.UseHttps(serverCertificate); + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + { + // ANCM is not hosting the process + options.Listen(IPAddress.Loopback, 44318, listenOptions => + { + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); + } }) - .UseUrls("https://localhost:44318") .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration() .UseStartup() diff --git a/samples/SocialSample/Program.cs b/samples/SocialSample/Program.cs index f3cad66ad3..483feec169 100644 --- a/samples/SocialSample/Program.cs +++ b/samples/SocialSample/Program.cs @@ -1,4 +1,6 @@ -using System.IO; +using System; +using System.IO; +using System.Net; using System.Reflection; using System.Security.Cryptography.X509Certificates; using Microsoft.AspNetCore.Hosting; @@ -14,9 +16,16 @@ namespace SocialSample var host = new WebHostBuilder() .UseKestrel(options => { - //Configure SSL - var serverCertificate = LoadCertificate(); - options.UseHttps(serverCertificate); + if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT"))) + { + // ANCM is not hosting the process + options.Listen(IPAddress.Loopback, 5000, listenOptions => + { + // Configure SSL + var serverCertificate = LoadCertificate(); + listenOptions.UseHttps(serverCertificate); + }); + } }) .UseContentRoot(Directory.GetCurrentDirectory()) .UseIISIntegration()