Passing Complex Objects to ASP.NET Web API Using FromUri

Viewed 1102

I want to bind the URL parameters to my Point object using attribute routing and the [FromUri] attribute such that the following URL is possible:

/foo-1,2

public IHttpActionResult PostFoo(
    [FromBody] string content,
    [FromUri] Point point)
{
}

public class Point
{
    public int A { get; set; }
    public int B { get; set; }

    // ...Other properties omitted for simplicity
}

I have tried the following Route attributes but none of these work:

[Route("foo-{a},{b}")]
[Route("foo-{A},{B}")]
[Route("foo-{point.A},{point.B}")]

Note that I can't use query string parameters because a badly built third party service does not accept ampersands in their URL's (Yes it's that bad). So I'm trying to build all query string parameters into the URL itself.

1 Answers
Related