C# - System.Data.SqlClient.SqlException: 'Failed to generate SSPI context.'

Set the parameter Trusted_Connection=False in your connection string.


I've had same problem recently. I changed my connection string to

"Server=10.10.127.170;Database=NGProd;user id=*;pwd=*;"

and it worked for me.

Hope this helps!


As it has been said, it can be caused by a range of issues. One of them is the AppPool Account in IIS. Confirm that it has permissions or you can update it from the default built-in account to the account you want to access the server with. Under the App Pool tied to your app, got to Advanced Settings > Process Model > Identity. Then choose Custom Account and enter your server account. See the screenshot below.enter image description here