I want to send a string via Angular $http to my ASP.NET C# backend. I am using web-forms. However, i get the following error:
POST http://localhost:49730/Default.aspx/get_requested_table 404 (Not Found)
My Angular controller looks like this:
App.controller("MainCtrl", function ($scope, $http) {
$scope.request_table = function (tableName) {
$http
.post("Default.aspx/get_requested_table", tableName)
.success(function (data) {
console.log("Success, it worked!");
});
};
});
And my HTML looks like this:
<button ng-click="request_table('tblMain')" type='button'>GET IT</button>
And my ASP.NET C# file (aka Default.aspx.cs):
public static string myTable;
[WebMethod]
public static string get_requested_table(string tableName)
{
var myTable = tableName;
Console.Write(myTable);
return myTable;
}
Am I doing something wrong to be getting this error? How can I use Angular's $http methods to speak with my C# backend?