Sample project can now redirect to HTTPS (#106)
Sample project can now redirect to HTTPS
This commit is contained in:
parent
ead052324c
commit
58ef98b184
|
|
@ -16,7 +16,7 @@ namespace RewriteSample
|
|||
var options = new RewriteOptions()
|
||||
.AddRedirect("(.*)/$", "$1")
|
||||
.AddRewrite(@"app/(\d+)", "app?id=$1")
|
||||
.AddRedirectToHttps(302)
|
||||
.AddRedirectToHttps(302, 5001)
|
||||
.AddIISUrlRewrite(env.ContentRootFileProvider, "UrlRewrite.xml")
|
||||
.AddApacheModRewrite(env.ContentRootFileProvider, "Rewrite.txt");
|
||||
|
||||
|
|
@ -28,7 +28,11 @@ namespace RewriteSample
|
|||
public static void Main(string[] args)
|
||||
{
|
||||
var host = new WebHostBuilder()
|
||||
.UseKestrel()
|
||||
.UseKestrel(options =>
|
||||
{
|
||||
options.UseHttps("testCert.pfx", "testPassword");
|
||||
})
|
||||
.UseUrls("http://localhost:5000", "https://localhost:5001")
|
||||
.UseStartup<Startup>()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.Build();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@
|
|||
"version": "1.1.0-*",
|
||||
"dependencies": {
|
||||
"Microsoft.AspNetCore.Rewrite": "1.1.0-*",
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*"
|
||||
"Microsoft.AspNetCore.Server.Kestrel": "1.1.0-*",
|
||||
"Microsoft.AspNetCore.Server.Kestrel.Https": "1.1.0-*"
|
||||
},
|
||||
"buildOptions": {
|
||||
"emitEntryPoint": true,
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -12,14 +12,12 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlActions
|
|||
[Fact]
|
||||
public void Forbidden_Verify403IsInStatusCode()
|
||||
{
|
||||
// Arrange
|
||||
|
||||
var context = new RewriteContext {HttpContext = new DefaultHttpContext()};
|
||||
var action = new ForbiddenAction();
|
||||
|
||||
// Act
|
||||
action.ApplyAction(context, null, null);
|
||||
|
||||
// Assert
|
||||
|
||||
Assert.Equal(context.Result, RuleResult.EndResponse);
|
||||
Assert.Equal(context.HttpContext.Response.StatusCode, StatusCodes.Status403Forbidden);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,11 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.UrlActions
|
|||
[Fact]
|
||||
public void Gone_Verify410IsInStatusCode()
|
||||
{
|
||||
// Arrange
|
||||
var context = new RewriteContext { HttpContext = new DefaultHttpContext() };
|
||||
var action = new GoneAction();
|
||||
|
||||
// Act
|
||||
action.ApplyAction(context, null, null);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(context.Result, RuleResult.EndResponse);
|
||||
Assert.Equal(context.HttpContext.Response.StatusCode, StatusCodes.Status410Gone);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue