I am building an application with the following flow My Controller will call the View. Inside the view i am calling a js file which has angularjs code with makes a call to the APIController.
I am getting the following error :
Request URL:http://localhost:52096/api/EVerify/GetEmployeeList
Request Method:POST
Status Code:404 Not Found
What am i missing or doing wrong.
Controller :
using System.Web.Mvc;
namespace MVC.EVerify.Controllers
{
[Authorize]
public class EVerifyController : Controller
{
#region Methods
#region ListEVerify
public ActionResult ListEVerify()
{
if (Request.IsAjaxRequest()) return PartialView();
return View();
}
#endregion
}
View :
In this view on click of a button I am loading another view along with Javascript file which has angular code called EverifyModule.js
<table>
<tbody>
<tr ng-repeat="emp in EmployeeInfo">
<td>{{emp.name}}</td>
<td>{{emp.hireDate}}</td>
<td><a class="btn-sm btn-primary pull-right" href="javascript:void(0)" onclick="LoadViewSelected('/EVerify/EVerify/EVerifySubmit', 'EVerifyModule', 'E-VerifySubmit');">E-Verify</a></td>
</tr>
</tbody>
</table>
EVerifyModule.js
var EVerifyModule = angular.module('EVerifyModule', ['angularFileUpload', 'ui.bootstrap', 'angularUtils.directives.dirPagination']);
EVerifyModule.factory('EVerifyModuleService', ['$http', '$window', function ($http, $window) {
return {
GetEmployeeList: function (companyId) {
return $http({
url: '/api/EVerify/GetEmployeeList',
method: 'POST',
data: companyId
});
}
};
}]);
EVerifyModule.controller('EVerifyController', ['$scope', '$http', '$compile', 'EVerifyModuleService', '$modal', '$timeout', function ($scope, $http, $compile, EVerifyModuleService, $modal, $timeout) {
EVerifyModuleService.GetEmployeeList(58).then(function (response) {
$scope.EmployeeInfo = response.data.Employees;
});
EVerifyAPIController :
namespace MVC.EVerify.Controllers
{
[RoutePrefix("api/EVerify")]
public class EVerifyAPIController : ApiController
{
#region GetEmployeeList
[HttpPost]
[Route("GetEmployeeList")]
public async Task<IHttpActionResult> GetEmployeeList(int CompanyId)
{
List<EmployeeBO> employees = new List<EmployeeBO>();
try
{
employees = await EmployeeBL.GetEmployeeList(CompanyId);
}
catch
{
employees = new List<EmployeeBO>();
}
return Ok(new { Employees = employees });
}
#endregion
}
}