InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found in ASP.NET Core 2.0
13,959
You need the following in Startup.cs
:
services.AddAuthentication(IISDefaults.AuthenticationScheme);
Related videos on Youtube
Author by
Mischa Morf
Updated on June 04, 2022Comments
-
Mischa Morf almost 2 years
Im using ASP.net core 2 in an mvc web application. Im currently authorizing from an AD group on one Controller action, and it worked fine on the localhost so far. Now after publishing, instead of getting the log in window I get the following error:
InvalidOperationException: No authenticationScheme was specified, and there was no DefaultChallengeScheme found.
This is how I authorize the AD role.
[Authorize(Roles = "Domain Users")]
Do i need to add something to the startup.cs or am I missing something else?
-
Mischa Morf about 5 yearslacking time right now to do that. U know if there is an easy way to fix this though? @nyulan
-
nyulan about 5 yearsshow startup.cs
-
Chris Pratt about 5 years@nyulan: That doesn't work in ASP.NET Core.
AuthorizeAttribute
is merely a placeholder now. The actual work of auth happens via other facilities, i.e. there is noAuthorizeCore
method to override.
-
-
Mischa Morf about 5 yearsworked thanks. Any idea on a action that logs that authorized user out again?
-
Chris Pratt about 5 yearsDepends on your exact scenario. I don't think you can in a Windows Auth scenario. But, perhaps using ADFS as a provider.