I have the following angularjs code:
$http.get("/Home/GetEmails").then(function (response) {
$scope.emails = response.data;
$scope.init($scope.emails);
$scope.totalEmails = $scope.emails.length;
});
When I develop locally, it works fine, but when I publish to a live server, it gives the following error message:
Failed to load resource: the server responded with a status of 404 (Not Found). It is looking for http://xaisoft.com/Home/GetEmails, but it can't find it. Is there something else I need to do in ASP.NET MVC and/or Angular to get this to work. Currently, I just have the GetEmails action return a JSON object in my HomeController.
HomeController
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public ActionResult GetEmails()
{
return Json(new[]
{
new
{
from = "Jet Blue",
to = "Me",
subject = "Buy one seat, get one free!",
body = "That and helping Data finish 'Pop Goes the Weasel'. Also counts as a CMOH.",
date = "Dec 20th 12:22 PM",
isImportant = false,
isStarred = true,
isChecked = false,
isRead = true
},
new
{
from = "Publix",
to = "Me",
subject = "Check this weeks BOGO deals",
body = "Hurry, ends Thursday!",
date = "Mar 15th 8:15 AM",
isImportant = false,
isStarred = false,
isChecked = false,
isRead = false
},
new
{
from = "AJ Carpio",
to = "Me",
subject = "When Life Gives You Questions, Google has Answers",
body = "Get more life quotes here",
date = "Mar 15th 8:15 AM",
isImportant = true,
isStarred = false,
isChecked = false,
isRead = true
}
},JsonRequestBehavior.AllowGet);
}
}