添加重定向规则以强制执行 https:
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
var options = new RewriteOptions()
.AddRedirectToHttps();
app.UseRewriter(options);
服务清单:
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint1" Protocol="http" Port="80"/>
<Endpoint Name="ServiceEndpoint2" Protocol="https" Port="443"/>
</Endpoints>
</Resources>
通讯听众:
var endpoints = Context.CodePackageActivationContext.GetEndpoints()
.Where(endpoint => endpoint.Protocol == EndpointProtocol.Http || endpoint.Protocol == EndpointProtocol.Https)
.Select(endpoint => endpoint.Name);
return endpoints
.Select(endpoint => new ServiceInstanceListener(serviceContext =>
new KestrelCommunicationListener(serviceContext, endpoint), (url, listener) =>{[..]}));