Added OriginalQueryString property to IStatusCodeReExecuteFeature interface

This commit is contained in:
Kiran Challa 2017-01-04 15:19:44 -08:00
parent f35a3b4918
commit fb7c25b662
3 changed files with 27 additions and 5 deletions

View File

@ -8,5 +8,7 @@ namespace Microsoft.AspNetCore.Diagnostics
string OriginalPathBase { get; set; } string OriginalPathBase { get; set; }
string OriginalPath { get; set; } string OriginalPath { get; set; }
string OriginalQueryString { get; set; }
} }
} }

View File

@ -0,0 +1,14 @@
[
{
"OldTypeId": "public interface Microsoft.AspNetCore.Diagnostics.IStatusCodeReExecuteFeature",
"NewTypeId": "public interface Microsoft.AspNetCore.Diagnostics.IStatusCodeReExecuteFeature",
"NewMemberId": "System.String get_OriginalQueryString()",
"Kind": "Addition"
},
{
"OldTypeId": "public interface Microsoft.AspNetCore.Diagnostics.IStatusCodeReExecuteFeature",
"NewTypeId": "public interface Microsoft.AspNetCore.Diagnostics.IStatusCodeReExecuteFeature",
"NewMemberId": "System.Void set_OriginalQueryString(System.String value)",
"Kind": "Addition"
}
]

View File

@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Diagnostics
} }
[Fact] [Fact]
public async Task Reexecute_RequestWithQueryString() public async Task Reexecute_CanRetrieveInformationAboutOriginalRequest()
{ {
var expectedStatusCode = 432; var expectedStatusCode = 432;
var destination = "/location"; var destination = "/location";
@ -241,7 +241,7 @@ namespace Microsoft.AspNetCore.Diagnostics
Assert.Equal(beforeNext, afterNext); Assert.Equal(beforeNext, afterNext);
}); });
app.UseStatusCodePagesWithReExecute("/errorPage", "?id={0}"); app.UseStatusCodePagesWithReExecute(pathFormat: "/errorPage", queryFormat: "?id={0}");
app.Map(destination, (innerAppBuilder) => app.Map(destination, (innerAppBuilder) =>
{ {
@ -256,7 +256,13 @@ namespace Microsoft.AspNetCore.Diagnostics
{ {
innerAppBuilder.Run(async (httpContext) => innerAppBuilder.Run(async (httpContext) =>
{ {
await httpContext.Response.WriteAsync(httpContext.Request.QueryString.Value); var statusCodeReExecuteFeature = httpContext.Features.Get<IStatusCodeReExecuteFeature>();
await httpContext.Response.WriteAsync(
httpContext.Request.QueryString.Value
+ ", "
+ statusCodeReExecuteFeature.OriginalPath
+ ", "
+ statusCodeReExecuteFeature.OriginalQueryString);
}); });
}); });
@ -269,9 +275,9 @@ namespace Microsoft.AspNetCore.Diagnostics
using (var server = new TestServer(builder)) using (var server = new TestServer(builder))
{ {
var client = server.CreateClient(); var client = server.CreateClient();
var response = await client.GetAsync(destination); var response = await client.GetAsync(destination + "?name=James");
var content = await response.Content.ReadAsStringAsync(); var content = await response.Content.ReadAsStringAsync();
Assert.Equal($"?id={expectedStatusCode}", content); Assert.Equal($"?id={expectedStatusCode}, /location, ?name=James", content);
} }
} }