Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions AspNetCoreRequestTracing.Tests/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddMvc();
#endif

#if NETCOREAPP3_0
#if NETCOREAPP3_0_OR_GREATER
services.AddControllers();
#endif
}
Expand All @@ -28,7 +28,7 @@ public void Configure(IApplicationBuilder app)
#if NETCOREAPP2_2
app.UseMvc();
#endif
#if NETCOREAPP3_0
#if NETCOREAPP3_0_OR_GREATER
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
#endif
Expand Down
3 changes: 2 additions & 1 deletion AspNetCoreRequestTracing/AspNetCoreRequestTracing.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.0;net5.0</TargetFrameworks>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
Expand All @@ -20,6 +20,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0" Condition="'$(TargetFramework)'=='netcoreapp2.1'" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.1.0" Condition="'$(TargetFramework)'=='netcoreapp2.1'" />
<FrameworkReference Include="Microsoft.AspNetCore.App" Condition="'$(TargetFramework)'=='netcoreapp3.0'" />
<FrameworkReference Include="Microsoft.AspNetCore.App" Condition="'$(TargetFramework)'=='net5.0'" />
<PackageReference Include="Microsoft.IO.RecyclableMemoryStream" Version="1.2.2" />
</ItemGroup>

Expand Down
5 changes: 3 additions & 2 deletions AspNetCoreRequestTracing/RequestTracingMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public async Task Invoke(HttpContext context, IOptions<RequestTracingMiddlewareO
#if NETCOREAPP2_1
context.Request.EnableRewind();
#endif
#if NETCOREAPP3_0
#if NETCOREAPP3_0_OR_GREATER
context.Request.EnableBuffering();
#endif

Expand Down Expand Up @@ -99,7 +99,8 @@ private bool IsMatch(IEnumerable<string> pathMatches, HttpRequest request)
{
try
{
if (Regex.IsMatch(request.Path, pathMatch))
string path = string.Concat(request.PathBase, request.Path);
if (Regex.IsMatch(path, pathMatch))
{
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static async Task RequestTrace(this ILogger logger, HttpRequest request)
_requestTrace(
logger,
request.Method,
$"{request.Scheme}://{request.Host}{request.Path}{request.QueryString}",
$"{request.Scheme}://{request.Host}{request.PathBase}{request.Path}{request.QueryString}",
request.Protocol,
request.Headers.AllHeadersAsString(),
request.Body == null ? string.Empty : await new StreamReader(request.Body).ReadToEndAsync(),
Expand Down