When running the default Identity scaffolding project from VS Code, I get this error when logging-in;
VS Code DEBUG CONSOLE:
---removed for brevity---
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 GET http://localhost:48154/
Microsoft.AspNetCore.Authorization.DefaultAuthorizationService:Information: Authorization failed for user: (null).
info: Microsoft.AspNetCore.Authorization.DefaultAuthorizationService[2]
Authorization failed for user: (null).
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker:Information: Authorization failed for the request at filter 'Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter'.
info: Microsoft.AspNetCore.Mvc.ChallengeResult[1]
Executing ChallengeResult with authentication schemes ().
Microsoft.AspNetCore.Mvc.ChallengeResult:Information: Executing ChallengeResult with authentication schemes ().
info: Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler[12]
AuthenticationScheme: Identity.Application was challenged.
Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler:Information: AuthenticationScheme: Identity.Application was challenged.
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
---removed for brevity---
I already installed the extension MSSQL, which I'm able to fetch records and viewable within the Menu panel (toolbar).
However, running the same project from Visual Studio 2019 Community, I can login just fine with no issue.
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
Member
323 Points
1308 Posts
VS Code - Authorization failed for user: (null)
Aug 09, 2020 01:52 AM|imperialx|LINK
Hi,
When running the default Identity scaffolding project from VS Code, I get this error when logging-in;
VS Code DEBUG CONSOLE:
I already installed the extension MSSQL, which I'm able to fetch records and viewable within the Menu panel (toolbar).
However, running the same project from Visual Studio 2019 Community, I can login just fine with no issue.
Any VS Code extension I'm missing?
Thanks,
Contributor
2900 Points
852 Posts
Re: VS Code - Authorization failed for user: (null)
Aug 10, 2020 07:46 AM|Sean Fang|LINK
Hi imperialx,
It looks like your project missing the authentication middleware: app.UseAuthentication().
I am just guessing since you don't post any code for the configuration. Could you please share the codes in startup.cs?
You could refer to this SO link: Authorization failed for user: (null)
Please be sure to call
UseAuthentication()
before callingUseMvc()
inStartup.Configure()
Regarding the authentication middleware : please refer to Auth 2.0 Migration announcement
Hope this can help you.
Best regards,
Sean
Member
323 Points
1308 Posts
Re: VS Code - Authorization failed for user: (null)
Aug 11, 2020 04:15 AM|imperialx|LINK
Hi Sean,
<div> <div> I still have the same issue even calling UseAuthentication() before UseMVC().</div> <div></div> <div></div> <div>Thanks,</div> <div></div> </div>