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