Skip to content

Instantly share code, notes, and snippets.

@PradeepLoganathan
Last active June 30, 2020 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PradeepLoganathan/13760220d8029beb5273f28c7c652e99 to your computer and use it in GitHub Desktop.
Save PradeepLoganathan/13760220d8029beb5273f28c7c652e99 to your computer and use it in GitHub Desktop.
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