i am create small demo for getting user list.i am using for this web api with angularjs mvc c#. i am view this list for used jquery datatable with angularjs.
i am trying for view list of user then getting error like this in console "Server Error in '/' Application".
here my angulr.js code:
app.controller('Usercontroller', ['$scope', '$http', 'DTOptionsBuilder', 'DTColumnBuilder',
function ($scope, $http, DTOptionsBuilder, DTColumnBuilder) {
$scope.dtColumns = [
//DTColumnBuilder.newColumn("id", "User ID"),
DTColumnBuilder.newColumn("firstname", "First Name"),
DTColumnBuilder.newColumn("lastname", "Last Name"),
]
$scope.dtOptions = DTOptionsBuilder.newOptions().withOption('ajax', {
url: "/User/GetUsers",
type: "GET"
})
.withPaginationType('full_numbers')
.withDisplayLength(10);
}])
here my controller code:
[HttpGet]
public IHttpActionResult GetUsers()
{
return Json(db.Users.ToList());
}
i don't know where is my mistake any one know then please let me know.