My javascript method-
visitorApp.controller('LoginController', function ($scope,$http) {
$scope.submit = function (isValid) {
if (isValid) {
var loginModel = {
UserName: $scope.UserName,
PassWord: $scope.Password
};
$http.post(
'/api/VisitorWeb/VerfiyLogin',
JSON.stringify(loginModel),
{
headers: {
'Content-Type': 'application/json'
}
}
).success(function (data) {
alert("Hi" +data);
$scope.message = data;
});
}
}
});
My web api method -
[HttpPost]
public UserLoginDomainModel VerifyLogin(UserLoginDomainModel loginModel)
{
//do some business logic
return loginModel;
}
My webapiconfig file
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.Formatters.JsonFormatter.SupportedMediaTypes.Add(new MediaTypeHeaderValue("text/html"));
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{action}"
);
}
}
I am getting 404 response from server.
"NetworkError: 404 Not Found - http://localhost:43516/api/VisitorWeb/VerfiyLogin"
I was try to follow this link POSTing from Angular to .net WebAPI but some how it is not working for me.