I've built a web api for my mobile app. I test it on the localhost in browser and it returns json as expected, but whenever I host it on azure and hit the same URL I receive no data, but google network (developer console) in chrome says it has retrieved 408B of data, but no content shows up where the json should be present?
What could I not have configured correctly?
I have gone into the Global.ascx file and added the following line of code
public static void Register(HttpConfiguration config)
{
config.EnableCors();
}
and added the EnableCors attribute on top of the webapi controller class and set the prefix router too.
What am I missing?
Controller code see below for a snippet of it. the database is an EF Code First generated from a database that already existed. Please note.
[EnableCors(origins: "*", headers: "*", methods: "*")]
[RoutePrefix("api/numbers")]
[AllowAnonymous]
public class NumbersController : ApiController
{
private MegaMillions db = new MegaMillions();
[HttpGet]
public HttpResponseMessage Get()
{
return db.Numbers.Take(10).ToList();
}
// GET: api/Numbers
public List<Number> GetNumbers()
{
return db.Numbers.ToList();
}
}
if I can figure out how to get the list working the other CRUD operations will follow suit.