Right now RouteDataValueProvider converts all route data to strings using ToString.
```
public class RouteDataValueProvider : NameValuePairsValueProvider
{
public RouteDataValueProvider(HttpActionContext actionContext, CultureInfo culture)
: base(GetRouteValues(actionContext.ControllerContext.RouteData), culture)
{
}
internal static IEnumerable<KeyValuePair<string, string>> GetRouteValues(IHttpRouteData routeData)
{
foreach (KeyValuePair<string, object> pair in routeData.Values)
{
string value = (pair.Value == null) ? null : pair.Value.ToString();
yield return new KeyValuePair<string, string>(pair.Key, value);
}
}
```
This poses problems for custom routes that try to insert pre-parsed data. For example, an OData route can parse a complex object from the URI(OData function parameter) and stuff the complex object into the route data.
Our RouteDataValueProvider would fail as it tries to convert it into string and then try to convert back from string to complex object.
For example, this scenario would be broken,
```
server.Configuration.Routes.MapHttpRoute("default", "{controller}/Redmond", new { Address = new Address("Redmond") });
public class CustomersController : ApiController
{
public Address Get([FromUri]Address address)
{
return address;
}
}
```
```
public class RouteDataValueProvider : NameValuePairsValueProvider
{
public RouteDataValueProvider(HttpActionContext actionContext, CultureInfo culture)
: base(GetRouteValues(actionContext.ControllerContext.RouteData), culture)
{
}
internal static IEnumerable<KeyValuePair<string, string>> GetRouteValues(IHttpRouteData routeData)
{
foreach (KeyValuePair<string, object> pair in routeData.Values)
{
string value = (pair.Value == null) ? null : pair.Value.ToString();
yield return new KeyValuePair<string, string>(pair.Key, value);
}
}
```
This poses problems for custom routes that try to insert pre-parsed data. For example, an OData route can parse a complex object from the URI(OData function parameter) and stuff the complex object into the route data.
Our RouteDataValueProvider would fail as it tries to convert it into string and then try to convert back from string to complex object.
For example, this scenario would be broken,
```
server.Configuration.Routes.MapHttpRoute("default", "{controller}/Redmond", new { Address = new Address("Redmond") });
public class CustomersController : ApiController
{
public Address Get([FromUri]Address address)
{
return address;
}
}
```