I have a Web API 2 that I am consuming using jQuery Ajax and looking through the documentation you can now include a route inside the Controller itself so you could include additional parameters inside the GET request for example.
I have tried adding this for example:
[Route("api/formHTML/{id}/{code}/{value}")]
public IEnumerable<string> Get(int id, int code, int value)
{
return new string[] {"<html><head></head><body>Test</body></html>"};
}
Which will basically return some HTML code.
I keep getting 404 not found when using a GET on api/formHTML/1/5/2
I still have this in my Global.asax which contains the default route mapping.
protected void Application_Start(object sender, EventArgs e)
{
GlobalConfiguration.Configuration.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}"
);
}
Does anyone know why I would be getting a 404?
I know I could get the values by sending them as data object in the Get Request and using formBody in the Web API but I ideally wanted to use the above convention.
Thanks