From fa64b0c0fb193c584d5d0835293860f92469145a Mon Sep 17 00:00:00 2001 From: Stephen Halter Date: Mon, 9 Jan 2017 19:58:22 -0800 Subject: [PATCH] React to UseHttps change --- samples/OpenIdConnectSample/Program.cs | 18 +++++++++++++----- samples/SocialSample/Program.cs | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 9 deletions(-) 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()