After running a ASP.NET website on IIS 7.5 for the first time on a Windows 7 computer, I was faced with the following error message:
Login failed for user 'IIS APPPOOL\ASP.NET v4.0'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'IIS APPPOOL\ASP.NET v4.0'.
To fix this issue, try changing the (Process Model) Identity of your website’s Application Pool to use the NetworkService account (or the less secure LocalSystem account). By default, IIS7 seems to set the Application Pools Identity to ‘ApplicationPoolIdentity’, instead of NetworkService or LocalSystem.
Here’s a step-by-step guide to determining your websites Application Pool, then changing its Process Model Idenitty in IIS7:
Now that we know the Application Pool that is configured for are website, we now want to change the app pool’s (Process Model) Identity to ‘NetworkService’, here’s how:
After changing the Application Pool’s Identity to NetworkService (or LocalSystem) you should now be able to get your ASP.NET site to run successfully on a IIS7 web server.
Source from http://www.gotknowhow.com/articles/fix-login-failed-for-user-iis-apppool-aspnet-v4-error-iis7