Reputation: 3370
I'd like to have a ApiController that has an action with a URI or URL parameter.
http://testserver/api/Controller?id=http://www.stackoverflow.com
I implemented actions like:
public bool Get(string id)
{
...
}
or
public bool Get(Uri id)
{
...
}
However: Whenever I call the URL as stated above, I get an 400 - Error - Bad Request.
Upvotes: 1
Views: 2865
Reputation: 3370
The problem seems to be that I used "Cassini", the VS integrated webserver. As soon as I ran it in IIS Express, it worked.
Upvotes: 0
Reputation: 1038730
I am unable to reproduce the problem you are describing. This should work. Here are the steps I have tried:
Add an Api controller:
public class ValuesController : ApiController
{
public HttpResponseMessage Get(Uri id)
{
return Request.CreateResponse(HttpStatusCode.OK, id);
}
}
Run the application and navigate to /api/values/?id=http%3A%2F%2Fwww.stackoverflow.com
So could you provide the steps allowing us to reproduce the problem?
Upvotes: 2