React to UseHttps change

This commit is contained in:
Stephen Halter 2017-01-09 19:58:22 -08:00
parent 9917e8bb30
commit fa64b0c0fb
2 changed files with 26 additions and 9 deletions

View File

@ -1,4 +1,6 @@
using System.IO; using System;
using System.IO;
using System.Net;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -12,12 +14,18 @@ namespace OpenIdConnectSample
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.UseKestrel(options => .UseKestrel(options =>
{
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT")))
{
// ANCM is not hosting the process
options.Listen(IPAddress.Loopback, 44318, listenOptions =>
{ {
// Configure SSL // Configure SSL
var serverCertificate = LoadCertificate(); var serverCertificate = LoadCertificate();
options.UseHttps(serverCertificate); listenOptions.UseHttps(serverCertificate);
});
}
}) })
.UseUrls("https://localhost:44318")
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()
.UseStartup<Startup>() .UseStartup<Startup>()

View File

@ -1,4 +1,6 @@
using System.IO; using System;
using System.IO;
using System.Net;
using System.Reflection; using System.Reflection;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
@ -13,10 +15,17 @@ namespace SocialSample
{ {
var host = new WebHostBuilder() var host = new WebHostBuilder()
.UseKestrel(options => .UseKestrel(options =>
{
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("ASPNETCORE_PORT")))
{
// ANCM is not hosting the process
options.Listen(IPAddress.Loopback, 5000, listenOptions =>
{ {
// Configure SSL // Configure SSL
var serverCertificate = LoadCertificate(); var serverCertificate = LoadCertificate();
options.UseHttps(serverCertificate); listenOptions.UseHttps(serverCertificate);
});
}
}) })
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration() .UseIISIntegration()