C# iis网站已移动到新目录,连接已禁用

C# iis网站已移动到新目录,连接已禁用,c#,asp.net,iis,C#,Asp.net,Iis,我是asp.net和IIS新手,我正在开发一个使用asp.net进行学习的网站。首先,我使用vwd创建了一个新的空白网站,物理目录是C:\inetpub\web1,但后来我将web1移动到C:\inetpub\wwwroot并打开了IIS,将目录转到应用程序并尝试使用浏览器运行它。出现错误消息 Server Error in '/web1' Application. Cannot open database "testdb" requested by the login. The login

我是asp.net和IIS新手,我正在开发一个使用asp.net进行学习的网站。首先,我使用vwd创建了一个新的空白网站,物理目录是C:\inetpub\web1,但后来我将web1移动到C:\inetpub\wwwroot并打开了IIS,将目录转到应用程序并尝试使用浏览器运行它。出现错误消息

Server Error in '/web1' Application.

Cannot open database "testdb" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.

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: Cannot open database "testdb" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.

Source Error: 


Line 34: 
Line 35:         SqlConnection dbCon = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString);
Line 36:         dbCon.Open();
Line 37: 

Source File: c:\inetpub\wwwroot\web1\App_Code\tree.cs    Line: 36 

Stack Trace: 


[SqlException (0x80131904): Cannot open database "test" requested by the login. The login failed.
Login failed for user 'IIS APPPOOL\DefaultAppPool'.]
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +1270
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +108
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
   System.Data.SqlClient.SqlConnection.Open() +125
   Node.buildTree(String contentType, String mode) in c:\inetpub\wwwroot\web1\App_Code\tree.cs:36
   header.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\web1\header.aspx.cs:14
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
有人知道问题出在哪里吗


谢谢

我很清楚这个错误:

用户“IIS APPPOOL\DefaultAppPool”在
DbConnectionPool.GetConnection
登录失败

我假设该站点以前位于由
NT AUTHORITY\NETWORK SERVICE
运行的应用程序池中,并且该用户使用集成安全性获得了您想要使用的数据库的权限


如果是这种情况,只需更改应用程序池运行时所使用的用户。

“更改应用程序池运行时所使用的用户”。如何操作?@HKSEACH。