In this tutorial we will learn how to solve
“System.Data.SqlClient.SqlException was unhandled by user code: Login failed for user 'IIS APPPOOL\DefaultAppPool’” and database connection couldn't open.
There are some step for solving this problem.
1. Go to your Run Window and there you type “Inetmgr” and click oK ( Means Go to IIS Server).
2. Here you will IIS Server window , from this window you go to “Application pools” and then select “DefaultAppPool” Right click on it and select “Advance Settings” and click on that.
3. When you will click on Advance setting link it will open Advance setting window there you select “Identity” (In Process Modal) and Change the path from ApplicationPoolIdentity to LocalSystem
When you will click on this Path three dotted button there a window will open from there “Built-in-Account “radio button contain a dropdown box , from this dropdown box you change this path and the click OK.