".net core BeginRequest EndRequest" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like ".net core BeginRequest EndRequest" answered properly. Developers are finding an appropriate answer about .net core BeginRequest EndRequest related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like .net core BeginRequest EndRequest. Enter your desired code related query in the search bar and get every piece of information about C# code related question on .net core BeginRequest EndRequest.
.net core BeginRequest EndRequest
//ref https://www.pluralsight.com/tech-blog/converting-http-modules-to-middleware/
//ref https://stackoverflow.com/questions/43403941/how-to-read-asp-net-core-response-body
app.UseMiddleware<RequestApplicationLogMiddleware>();
app.UseMiddleware<ResponseApplicationLogMiddleware>();
public async Task InvokeAsync(HttpContext context, IApplicationLog log)
{
_session.Id=Guid.NewGuid().ToString();
if (context.Request.Path.Value.Contains("api"))
{
log.SaveRqst(new { Header = context.Request.Headers, Data = context.Request.Body.ReadToEnd() }, context.Request.Path);
}
await _next(context);
}
public async Task InvokeAsync(HttpContext context, IApplicationLog log)
{
//await _next(context);
//log.SaveRsp(new { Header = context.Response.Headers, Data = context.Response.Body.ReadToEnd()}, context.Response.StatusCode.ToString(), context.Request.Path);
Stream originalBody = context.Response.Body;
try
{
using (var memStream = new MemoryStream())
{
context.Response.Body = memStream;
await _next(context);
memStream.Position = 0;
string responseBody = new StreamReader(memStream).ReadToEnd();
if (context.Request.Path.Value.Contains("api"))
{
log.SaveRsp(new { Header = context.Response.Headers, Data = responseBody }, context.Response.StatusCode.ToString(), context.Request.Path);
}
memStream.Position = 0;
await memStream.CopyToAsync(originalBody);
}
}
finally
{
context.Response.Body = originalBody;
}
}
All those coders who are working on the C# based application and are stuck on .net core BeginRequest EndRequest can get a collection of related answers to their query. Programmers need to enter their query on .net core BeginRequest EndRequest related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about .net core BeginRequest EndRequest for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of .net core BeginRequest EndRequest while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to ".net core BeginRequest EndRequest". Visit this developer's friendly online web community, CodeProZone, and get your queries like .net core BeginRequest EndRequest resolved professionally and stay updated to the latest C# updates.