Visual Studio 2017 with ASP.NET Core 1.1. Unit Testing with xUnit and Microsoft.AspNetCore.TestHost.TestServer
The code below, copied from the official core source code, works as expected, however, if you change the Uri to https://example.com, the response is 404:
[Fact]
public async Task CheckPermanentRedirectToHttps()
{
var options = new RewriteOptions().AddRedirectToHttpsPermanent();
var builder = new WebHostBuilder()
.Configure(app =>
{
app.UseRewriter(options);
});
var server = new TestServer(builder);
var response = await server.CreateClient().GetAsync(new Uri("http://example.com"));
Assert.Equal("https://example.com/", response.Headers.Location.OriginalString);
Assert.Equal(StatusCodes.Status301MovedPermanently, (int)response.StatusCode);
}
How can I make the https work like the http with the TestServer
?