Angular - GET方法 - ASP CORE - Windows身份验证 - 错误401.2 - 未经授权 [英] Angular - GET method - ASP CORE - windows authentication - error 401.2 - unauthorized
问题描述
我正在尝试使用Windows进行调用get方法,使用Windows身份验证,但我遇到了这个错误:
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."
我的代码Angular:
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)
}
我的.NET核心代码(服务器端):
My .NET Core Code (Server Side):
[Authorize]
[HttpGet]
[Route("api/teste")]
public string Teste()
{
return "Giovanni";
}
文件LaunchSettings.son:
File LaunchSettings.son:
"iisSettings": {
"windowsAuthentication": true,
"anonymousAuthentication": false,
"iisExpress": {
"applicationUrl": "http://localhost:50553/",
"sslPort": 0
}
谢谢。
我的尝试:
我试过这篇文章:
Windows身份验证Angular 4和Web Api Core |渐进式bvba [ ^ ]
Angular,.NET Core,IIS Express和Windows身份验证 - 使用Microsoft工具的程序员 [ ^ ]
Flip~JB! :使用Web API进行[Angular] Windows身份验证 [ ^ ]
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[^]
推荐答案
您是否尝试在Angular论坛中发布此内容?
Have you tried posting this in an Angular forum?
这篇关于Angular - GET方法 - ASP CORE - Windows身份验证 - 错误401.2 - 未经授权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!