I have a website (Alpha) running successfully on an IIS 7.5 webserver running on Windows Server 2008 R2.
I basically want to clone Alpha and have a second website Beta, the same as Alpha, but will have somewhat different code. I've created the second website and also created a second Application pool. As far as I can tell, the two application pools are configured the same: auto start, v4.0, Integrated, Identity: ApplicationPoolIdentity.
The second website (Beta) doesn't work if I connect it to its own Application Pool, but works fine if I connect it to Alpha's Application Pool. As far as I can remember, I did not do anything special to Alpha's Application Pool. As far as I can tell, the advanced settings are the same for both.
The failure Beta has when connected to its own Application Pool is is getting an unhandled exception: Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'
Any ideas on how to compare the two Application Pools, or to debug the overall system would be appreciated.
I tried deleting Beta's Application Pool and re-creating it.
You changed the account that pool Alpha runs under, but forgot to change pool Beta.
So pool Beta is still running under the default Networkservice (machine account), which doesn't have rights to your database.
Edit:
Another likely cause is that you are missing MS HotFix KB2545850 which will cause this issue seemingly randomly. See http://support.microsoft.com/kb/2545850
For details see this KB which also shows you how you can reproduce and confirm that this is the cause. http://support.microsoft.com/kb/2672809
You are connecting to a SQL-Server with integrated Security right? It seems the second pool identity does not have access to your SQL-Server/database.
Using ApplicationPoolIdentity, your app is connecting to SQL-Server as something like:
make sure that both Application pool identities have access to your server and the database in question.
I could create a Windows group to put the various Application pool identities in and then give that Windows group access to your database.
Also check this question, which seems to address a similar problem and suggest a reboot of the server.