How do you use both anonymous and windows authentication in ASP.NET Core 2.0 -


having trouble enabling both anonymous , windows authentication working when using http.sys webserver in asp.net core 2.0. works fine when host in iis refuses work in http.sys server. method tags [authorize] on homecontroller windows action fails http 500 , never prompts authentication.

program.cs

   .usehttpsys(options =>     {         options.authentication.schemes =  authenticationschemes.negotiate |     authenticationschemes.ntlm;         options.authentication.allowanonymous = true;         options.urlprefixes.add("http://localhost:5000");     }) 

homecontroller.cs

[authorize]     public class homecontroller : controller     {         [authorize]         public iactionresult windows()         {             return content ("you " + user.identity.name +  "; authentication type:" + user.identity.authenticationtype );         }          [allowanonymous]         public iactionresult anonymous()         {             return content ("you " + user.identity.name +  "; authentication type:" + user.identity.authenticationtype );;         }     } 

exception

an unhandled exception occurred while processing request.  invalidoperationexception: no authenticationscheme specified, , there no defaultchallengescheme found. microsoft.aspnetcore.authentication.authenticationservice+<challengeasync>d__11.movenext() 

need add following "services" section despite fact it's not hosted in iis

services.addauthentication(microsoft.aspnetcore.server.iisintegration.iisdefaults.authenticationscheme); 

per asp.net core 2.0 httpsys windows authentication fails authorize attribute (invalidoperationexception: no authenticationscheme specified)


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -