http://xxxx/api/garmin/data throws the following error
No type was found that matches the controller named 'garmin'.
Below is the code in Global.asax
void Application_Start(object sender, EventArgs e)
{
RouteTable.Routes.MapHttpRoute(
name: "ControllerAndAction",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = System.Web.Http.RouteParameter.Optional }
);
GlobalConfiguration.Configuration.Formatters.JsonFormatter.MediaTypeMappings.Add(new QueryStringMapping("type", "json", new MediaTypeHeaderValue("application/json")));
GlobalConfiguration.Configuration.Formatters.XmlFormatter.MediaTypeMappings.Add(new QueryStringMapping("type", "xml", new MediaTypeHeaderValue("application/xml")));
}
Controller Code
public class GraminController : ApiController
{
// GET
[HttpGet]
[ActionName("data")]
public string GetGarminData()
{
return "value";
}
}
The above code worked on the development server, but throws the below error
No HTTP resource was found that matches the request URI 'http://xxxx/api/garmin/data'. No type was found that matches the controller named 'garmin'.
What am I doing wrong? How can I fix the error?