I was running into some problems doing redirects/rewrites and became curious… so here’s hoping someone can “explain it to me like I’m five”
In Program.cs I have these lines:
var rewriteOptions = new RewriteOptions().AddRedirectToWwwPermanent();
app.UseRewriter(rewriteOptions);
app.UseHttpsRedirection();
By looking just a bit around, I can see that the RewriteOptions also have ways to add the HTTPS redirect – so why does this use a different method (on app directly)?
I’m used to controlling all of this in Web.config myself, which (IIRC) happens before Umbraco even sees the request (right?) So what’s the recommended approach here?
Can still do it in web.config and IIS will pick that up as normal prior to the asp.net process..
rewriteoptions will do this in the asp.net process, so webhost agnostic… say on linux, or locally in kestrel for testing
MS recommends using the highest upstream handler for obv reasons.. if IIS deals with it before aspnet process then you save compute assets.. though might be moot depending on the rules you actually need…
When to use URL rewriting middleware
Use URL Rewriting Middleware when the following approaches aren’t satisfactory: