나는 다음과 같은 AngularJS와 코드를 가지고 :
$http.get("/Home/GetEmails").then(function (response) {
$scope.emails = response.data;
$scope.init($scope.emails);
$scope.totalEmails = $scope.emails.length;
});
내가 로컬 개발할 때, 그것은 잘 작동하지만 라이브 서버에 게시 할 때, 그것은 다음과 같은 오류 메시지가 있습니다 :
Failed to load resource: the server responded with a status of 404 (Not Found)
합니다. http://xaisoft.com/Home/GetEmails을 찾고 있지만 찾을 수 없습니다. 이 기능을 사용하려면 ASP.NET MVC 및/또는 Angular에서해야 할 일이 있습니까? 현재, GetEmails 액션은 내 HomeController에서 JSON 객체를 반환합니다. 당신이 그랬던 것처럼
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);
}
}
당신이 404을 반환하는 브라우저에서 해당 URL을 방문하는 경우, 그래서 난을 게시하시기 바랍니다 AngularJS보다는 .NET 코드. 각도는 문제와 관련이없는 것 같습니다. –
@DanBowling - ASP.NET MVC HomeController를 게시했습니다. – xaisoft