Enforce HTTPS in ASP.NET Core: Use Status308PermanentRedirect (#31739)
* Enforce HTTPS in ASP.NET Core: Use Status308PermanentRedirect The previous paragraph says > Use the fields of the [StatusCodes](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.http.statuscodes) class for assignments to `RedirectStatusCode`. But the sample code then uses the status code defined in `System.Net` and a cast to `int`. * Use Status307TemporaryRedirect in other sample code (Program2.cs)pull/31924/head
parent
b76cb1bbcb
commit
68849ede7e
|
@ -1,4 +1,4 @@
|
|||
using System.Net;
|
||||
using static Microsoft.AspNetCore.Http.StatusCodes;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
@ -15,7 +15,7 @@ builder.Services.AddHsts(options =>
|
|||
|
||||
builder.Services.AddHttpsRedirection(options =>
|
||||
{
|
||||
options.RedirectStatusCode = (int)HttpStatusCode.TemporaryRedirect;
|
||||
options.RedirectStatusCode = Status307TemporaryRedirect;
|
||||
options.HttpsPort = 5001;
|
||||
});
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Net;
|
||||
using static Microsoft.AspNetCore.Http.StatusCodes;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
@ -8,7 +8,7 @@ if (!builder.Environment.IsDevelopment())
|
|||
{
|
||||
builder.Services.AddHttpsRedirection(options =>
|
||||
{
|
||||
options.RedirectStatusCode = (int)HttpStatusCode.PermanentRedirect;
|
||||
options.RedirectStatusCode = Status308PermanentRedirect;
|
||||
options.HttpsPort = 443;
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue