I have handler like below and I want to get method name from Controller
. Using var methodName = request.Method;
just return only type of method like 'GET' or 'POST'. How can I get method name, ex. from 'http://localhost:4200/weatherforecast/getitem/2 I want to return "getitem".
public class RequestAndResponseHandler : DelegatingHandler
{
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
if (request.Content != null)
{
string requestBody = await request.Content.ReadAsStringAsync();
Trace.WriteLine(requestBody);
}
var response = await base.SendAsync(request, cancellationToken);
if (response.Content != null)
{
var responseBody = await response.Content.ReadAsStringAsync();
Trace.WriteLine(responseBody);
}
var methodName = request.Method;
return response;
}
}