Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

How do I use both Windows and Anonymous authentication in HTTP.SYS server

$
0
0

Having trouble enabling both Anonymous and Windows authentication working when using http.sys as webserver in ASP.NET core 2.0. It works fine when I host in IIS but refuses to work in http.sys server. Method tags 

[Authorize]
 on HomeController 
Windows
 action fails with HTTP 500 and never prompts for 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 are " + User.Identity.Name +  "; Authentication Type:" + User.Identity.AuthenticationType );
        }

        [AllowAnonymous]
        public IActionResult Anonymous()
        {
            return Content ("You are " + User.Identity.Name +  "; Authentication Type:" + User.Identity.AuthenticationType );;
        }
    }

Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>