My post method is something like this:
public HttpResponseMessage AddUser(User user)
{
UserManager userManager = new UserManager();
try
{
userManager.Create(user);
var savedUser = userManager.FindUserByClientId(user.ClientId);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, user);
response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = savedUser.Id }));
return response;
}
catch(Exception ex)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
}
}
In angular, I am trying to read that Location header but so far I'm still not able to.
return $http.post('http://localhost:30028/api/values/adduser', user)
.success(function (data, status, headers, config) {
alert(angular.toJson(data));
alert(angular.toJson(status));
alert(angular.toJson(headers));
alert(angular.toJson(config));
};
I am just checking out the contents of each of those and none has the location header. Is there a way in angular to access the location header so that i know the url of my new object?