Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using HTTPS redirection
public void ConfigureServices(IServiceCollection services)
{
if (!_env.IsDevelopment())
{
services.AddHttpsRedirection(opts => {
opts.RedirectStatusCode = StatusCodes.Status308PermanentRedirect;
opts.HttpsPort = 44300;
});
}
else
{
services.AddHttpsRedirection(opts => {
opts.RedirectStatusCode = StatusCodes.Status307TemporaryRedirect;
opts.HttpsPort = 44300;
}
services.AddControllers();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.