I am trying call a get method with angular, using windows authentication, but i've had this error:
IIS 7.5 Detailed Error - 401.2 - Unauthorized
"status: 401,
ok: false,
statusText: 'Unauthorized',
headers:
Headers {
_headers:
Map {
'cache-control' => [Array],
'content-type' => [Array],
'server' => [Array],
'www-authenticate' => [Array],
'x-powered-by' => [Array],
'date' => [Array],
'content-length' => [Array] },
_normalizedNames:
Map {
'cache-control' => 'cache-control',
'content-type' => 'content-type',
'server' => 'server',
'www-authenticate' => 'www-authenticate',
'x-powered-by' => 'x-powered-by',
'date' => 'date',
'content-length' => 'content-length' } },
type: 2,
url: 'http://localhost/AppCoreWindowsAuthentication/api/teste' }
fail: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware[0]
An unhandled exception has occurred: Unexpected character encountered while parsing value: {. Path 'errorMessage', line 1, position 17."
My code Angular:
teste()
{
this.httpHeaders = new Headers({
'Content-Type': 'application/json',
'withCredentials': 'true'
});
return this._http.get(this.myAppUrl + 'api/teste', { headers: this.httpHeaders })
.map((response: Response) => <any>response.json())
.catch(this.errorHandler)
}
My .NET Core Code (Server Side):
[Authorize]
[HttpGet]
[Route("api/teste")]
public string Teste()
{
return "Giovanni";
}
File LaunchSettings.son:
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:50553/",
"sslPort": 0
}
Thanks.
What I have tried:
I've tried this articles:
Windows Authentication Angular 4 and Web Api Core | Progressive bvba[
^]
Angular , .NET Core, IIS Express and Windows Authentication – A Programmer with Microsoft tools[
^]
Flip~ JB ! : [Angular] Windows authentication with Web API[
^]