diff --git a/NDB.Logging.Api/NDB.Logging.Api.csproj b/NDB.Logging.Api/NDB.Logging.Api.csproj
index dc2ee36..e7ef3ca 100644
--- a/NDB.Logging.Api/NDB.Logging.Api.csproj
+++ b/NDB.Logging.Api/NDB.Logging.Api.csproj
@@ -7,6 +7,7 @@
https://dev.azure.com/tstanciu94/_git/NDB
.NET standard library for logging stuff in an API.
NDB NDB.Logging
+ 1.0.2
diff --git a/NDB.Logging.Api/RequestLoggingAttribute.cs b/NDB.Logging.Api/RequestLoggingAttribute.cs
index 435ec16..183700f 100644
--- a/NDB.Logging.Api/RequestLoggingAttribute.cs
+++ b/NDB.Logging.Api/RequestLoggingAttribute.cs
@@ -1,4 +1,4 @@
-using Microsoft.AspNetCore.Http.Internal;
+using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
@@ -25,7 +25,7 @@ namespace NDB.Logging.Api
stopWatch.Start();
var uid = Guid.NewGuid();
- var request = ((DefaultHttpRequest)((ControllerBase)context.Controller).Request);
+ var request = (HttpRequest)((ControllerBase)context.Controller).Request;
var requestUrl = request.Path;
if (request.QueryString != null && request.QueryString.HasValue)
@@ -51,16 +51,18 @@ namespace NDB.Logging.Api
_logger.LogDebug($"Request {uid} duration: {stopWatch.ElapsedMilliseconds:N0} ms");
}
- private async Task GetRequestBody(DefaultHttpRequest request)
+ private async Task GetRequestBody(HttpRequest request)
{
if (request.ContentLength == 0)
return "-";
- var body = new StreamReader(request.Body);
- body.BaseStream.Seek(0, SeekOrigin.Begin);
- var bodyStr = await body.ReadToEndAsync();
+ using (var body = new StreamReader(request.Body))
+ {
+ body.BaseStream.Seek(0, SeekOrigin.Begin);
+ var bodyStr = await body.ReadToEndAsync();
- return bodyStr;
+ return bodyStr;
+ }
}
}
}
\ No newline at end of file