Aspnetcore.docs: what is different with RewriteMiddleware

Created on 14 Jun 2018  Â·  6Comments  Â·  Source: dotnet/AspNetCore.Docs

use RewriteOptions.AddRedirectToHttps


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Source - Docs.ms

Most helpful comment

@Rick-Anderson How about a reverse note ... link from this topic (Enforce HTTPS) out to the URL Rewriting Middleware topic that says 'if you need to set the status code or status code and port, use the rewriting middleware.'

All 6 comments

Are you asking why AddRedirectToHttps is not used in place of app.UseHttpsRedirection(); ?

URL redirect to a secure endpoint uses AddRedirectToHttps

@Tratcher should that be updated to recommend app.UseHttpsRedirection(); ?
Why is app.UseHttpsRedirection(); used rather than RewriteOptions.AddRedirectToHttps ?

~You can set the status code and port with the URL Rewriting Middleware.~ Not the diff ... I noticed the new options on redirect middleware DO allow setting the status code and port. It's just that the URL Rewriting Middleware can handle additional redirect rules.

We already have this note in the URL Rewriting Middleware topic ...

When redirecting to HTTPS on port 443 without the requirement for additional redirect rules, we recommend using HTTPS Redirection Middleware. For more information, see the Enforce HTTPS topic.

@Rick-Anderson How about a reverse note ... link from this topic (Enforce HTTPS) out to the URL Rewriting Middleware topic that says 'if you need to set the status code or status code and port, use the rewriting middleware.'

@guardrex fantastic idea.

Sure ... piece of :cake:

Was this page helpful?
0 / 5 - 0 ratings