I add a DelegatingHandler for logging in my current MVC API. I tried to use i18n for multiple languages support. But the response content is not translated.it returns original string with [[[]]]. My DelegatingHandler code like follows:
public class LogRequestResponseHandler : DelegatingHandler
{
...
protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// log request body
...
// let other handlers process the request
var result = await base.SendAsync(request, cancellationToken);
// log response body
string responseBody = string.Empty;
if (result?.Content != null)
{
responseBody = await result.Content.ReadAsStringAsync();
}
_logger.Debug($"{request.RequestUri}, {request.Method.Method}, Status: {result.StatusCode} Success: {result.IsSuccessStatusCode}, Response body: {responseBody}");
return result;
}
}
it can work when I commented result.Content.ReadAsStringAsync() in above code.
I add a DelegatingHandler for logging in my current MVC API. I tried to use i18n for multiple languages support. But the response content is not translated.it returns original string with [[[]]]. My DelegatingHandler code like follows:
public class LogRequestResponseHandler : DelegatingHandler { ... protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
// log request body
...
it can work when I commented result.Content.ReadAsStringAsync() in above code.