Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON' in IIS

-1

I've got my c# web app working on the local computer with IIS Express (Visual Studio), and have installed it on an IIS 2016 web server and I get this application error when I try to access the database:

System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'

I am using Windows authentication through to the SQL database, in my web.config I have these settings and connection string:

 <system.web>
    <compilation debug="true" targetFramework="4.6.2" />
    <httpRuntime targetFramework="4.6.2" />
    <authentication mode="Windows" />
    <identity impersonate="true" />
    <authorization>
      <deny users="?" />
    </authorization>
</system.web>
<connectionStrings>
    <add name="DBconnectionString" 
         connectionString="Server=XXXXX\XXX;Initial Catalog=xxxxxx;Integrated Security=SSPI;" 
         providerName="System.Data.SqlClient" /> 
<connectionStrings>

In IIS I have set:

Windows Authentication: Enabled
ASP.NET Impersonation: Enabled
the others are disabled

I have added a test in my HomeController.cs to have it display my username:

ViewBag.Username = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

this works as expected.

I've spent ages searching and the only answers I can find say to put in a username/password into the connection string. This is not possible, user credentials need to be passed though to the database.

I'm thinking this is an IIS configuration problem, but cannot see where the issue is.

c#
sql-server
iis
asked on Stack Overflow Jun 14, 2019 by kazzle101

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0