Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
In ASP.NET Core 6.0, the HTTPS Redirection Middleware throws an exception of type InvalidOperationException when it finds multiple HTTPS ports in the server configuration. The exception's message contains the text "Cannot determine the https port from IServerAddressesFeature, multiple values were found. Set the desired port explicitly on HttpsRedirectionOptions.HttpsPort."
For discussion, see GitHub issue dotnet/aspnetcore#29222.
ASP.NET Core 6.0
When the HTTPS Redirection Middleware isn't explicitly configured with a port, it searches IServerAddressesFeature during the first request to determine the HTTPS port to which it should redirect.
If there are no HTTPS ports or multiple distinct ports, it's unclear which port should be used. The middleware logs a warning and disables itself. HTTP requests are processed normally.
When the HTTPS Redirection Middleware isn't explicitly configured with a port, it searches IServerAddressesFeature
during the first request to determine the HTTPS port to which it should redirect.
If there are no HTTPS ports, the middleware still logs a warning and disables itself. HTTP requests are processed normally. This behavior supports:
If there are multiple distinct ports, it's unclear which port should be used. The middleware throws an exception and fails the HTTP request.
This change prevents potentially sensitive data from being served over unencrypted HTTP connections when HTTPS is known to be available.
To enable HTTPS redirection when the server has multiple distinct HTTPS ports, you must specify one port in the configuration. For more information, see Port configuration.
If you don't need the HTTPS Redirection Middleware in your app, remove UseHttpsRedirection
from Startup.cs.
If you need to select the correct HTTPS port dynamically, provide feedback in GitHub issue dotnet/aspnetcore#21291.
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 9 PM - Mar 21, 10 AM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Customize ASP.NET Core behavior with middleware - Training
Understand and implement middleware in an ASP.NET Core app. Use included middleware like HTTP logging and authentication. Create custom middleware to handle requests and responses.