aspnet / BasicMiddleware

[Archived] Basic middleware components for ASP.NET Core. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
169 stars 84 forks source link

AddRedirectToHttps ignores statusCode #172

Closed cincuranet closed 7 years ago

cincuranet commented 7 years ago

When using the AddRedirectToHttps with statusCode, the statusCode is ignored. It's always 302. Same applies for AddRedirectToHttpsPermanent where 301 is expected.

I believe the problem is in RedirectToHttpsRule class here. It's using the Redirect, which defaults to 302 and the StatusCode property is ignored.

Tratcher commented 7 years ago

@muratg recomend accept for 1.1.0. Compare to the generic redirect rule: https://github.com/aspnet/BasicMiddleware/blob/03b63e2c2a5ec27deef4be692ff2119188b67d73/src/Microsoft.AspNetCore.Rewrite/Internal/RedirectRule.cs#L56

The tests don't actually check the status code: https://github.com/aspnet/BasicMiddleware/blob/9814f3bfbcf3a11dc86c4047fbfc2fe48744f96c/test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs#L67

muratg commented 7 years ago

(FYI for folks -- I have made the previous triage edits on the bug, not @cincuranet. Looks like there's a GH issue where it appears to put his name instead of mine.)

mikaelm12 commented 7 years ago

Good catch @cincuranet . Just fixed this issue in https://github.com/aspnet/BasicMiddleware/pull/173