I was recently working on an ASP.Net project and was receiving this error on attempting to
.Open() my SQL Server database connection:
System.Data.SqlClient.SqlException: Cannot generate SSPI context.
As you may have noticed, the connection uses SSPI (i.e. Windows login authentication) to connect to SQL Server. I thought this was a bit strange and tried restarting the project (it was running in debug mode). That didn’t help.
Fortunately, I remembered that my Windows password was set to expire today. It had expired while I was logged in, and so, was preventing me from being able to authenticate my login with SQL Server.
So, if you’re receiving this error, try updating your password if it may have expired.