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

Unable to get authenticationType in ASP.NET Core Web API

$
0
0

Question on Stackoverflow: https://stackoverflow.com/questions/45684877/unable-to-get-authenticationtype-in-asp-net-core-web-api

I'm writing a simple ASP.NET Core Web API that needs to return "true" if the authentication type of the logged in user is "Kerberos", and "false" otherwise. The code that works is:

public IEnumerable<string> Get()
{
    if(User?.Identity?.IsAuthenticated == true)
    {
        return new String[] { "true" };
    }
    return new String[] { "false" };
}

However, if I change the "IsAuthenticated" to "AuthenticationType" and check for the string value "Kerberos" as follows:

publicIEnumerable<string>Get(){if(User?.Identity?.AuthenticationType=="Kerberos"){returnnewString[]{"true"};}returnnewString[]{"false"};}

Then it starts throwing an error 500 if I run it on a Windows Server 2012 R2 based IIS Server. If I run it within Visual Studio (on the localhost - a domain-joined Windows 10 machine), it produces the right result.

What am I doing wrong?


Viewing all articles
Browse latest Browse all 9386

Trending Articles



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