I have a ASP.NET MVC application in VS 2010. I added a new Web API Controller to my application. Here is the simple method I am trying to call:
public List<Article> Get()
{
using (var db = new HighOnCodingDbEntities())
{
var articles = (from a in db.Articles
select a).Take(10).ToList();
return articles;
}
}
Global.asax:
routes.MapHttpRoute(
name: "API Default",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
When I call this method I get "Resource Not Found". I have published the application binary to the production and I believe that is all I need to do.
URL should be: http://www.highoncoding.com/api/articlesapi
ArticlesAPIController.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using HighOnCoding.Models;
namespace HighOnCoding.Controllers
{
public class ArticlesAPIController : ApiController
{
// GET api/<controller>
public List<Article> Get()
{
using (var db = new HighOnCodingDbEntities())
{
var articles = (from a in db.Articles
select a).Take(10).ToList();
return articles;
}
}
// GET api/<controller>/5
public string Get(int id)
{
return "value";
}
// POST api/<controller>
public void Post(string value)
{
}
// PUT api/<controller>/5
public void Put(int id, string value)
{
}
// DELETE api/<controller>/5
public void Delete(int id)
{
}
}
}
Works on local machine:

How's the controller class containing this method called?