Last active
June 30, 2020 07:56
-
-
Save PradeepLoganathan/13760220d8029beb5273f28c7c652e99 to your computer and use it in GitHub Desktop.
Using HTTPS redirection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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