Click here to Skip to main content
15,888,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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[^]
Posted
Updated 20-Jul-18 2:12am
Comments

1 solution

Have you tried posting this in an Angular forum?
 
Share this answer
 
Comments
Richard Deeming 20-Jul-18 11:13am    
If you want to post a comment, click the "Have a Question or Comment?" button under the question.

DO NOT post a comment as a "solution".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900