My application is a classic Asp.Net application and not MVC. Now i want to add ApiController to it.
I have added following API Controller
public class AlfrescoController : ApiController { [System.Web.Http.Route("api/alfresco")] public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/<controller>/5 public string Get(int id) { return "value"; } // POST api/<controller> public void Post([FromBody]string value) { } } My routing code in Global.asax is like below,
protected void Application_Start(object sender, EventArgs e) { RouteTable.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); } Now when i try to request http://localhost:52182/api/alfresco/, it gives me following error,
This XML file does not appear to have any style information associated with it. The document tree is shown below. No HTTP resource was found that matches the request URI 'http://localhost:52182/api/alfresco/'. No type was found that matches the controller named 'alfresco'.
Please let me know if i am doing anything wrong here, i have tried all the solutions from stackoverflow, nothing seems to work