In the angularjs part I have this part of the code to show the request-headers from the web:
$http.defaults.headers.common["User"] = "MjM=";
$http.defaults.headers.common["Password"] = "MjM=";
$http({
method: "GET",
url: "http://localhost/route/",
setRequestHeader: {
"User": $http.defaults.headers.common.User,
"Password": $http.defaults.headers.common.Password
}
});
I am using the verison 1.5.0 of angularjs. Apparently from angularjs I think that everything works correctly since chrome visualize ls request-headers that we are creating here:
Then, when we go to our code in c #, we put the corresponding configuration:
[Route("Token")]
[HttpGet, HttpOptions, HttpPost, HttpPut, HttpDelete]
[AcceptVerbs("OPTIONS")]
[EnableCors(origins: "http://localhost:61291",headers:"user, password", methods:"*")]
And after that the function in which I collect the values of the headers, and here is where the problem is:
var Datos = Request.Headers;
var token = Datos.GetValues("User");
var token = Datos.GetValues("Password");
Then I do an if to control possible failures, but the problem is that the function GetValues of header in question, always returns NULL.