I searched a lot before putting the questions here but the more I search the more confused I get.
So I have created an handler and I am trying to get the route like
I think you can get route Data from request.Properties property and easy to unit test.
///
/// Gets the for the given request or null if not available.
///
/// The HTTP request.
/// The or null.
public static IHttpRouteData GetRouteData(this HttpRequestMessage request)
{
if (request == null)
{`enter code here`
throw Error.ArgumentNull("request");
}
return request.GetProperty(HttpPropertyKeys.HttpRouteDataKey);
}
private static T GetProperty(this HttpRequestMessage request, string key)
{
T value;
request.Properties.TryGetValue(key, out value);
return value;
}
Reference link of code