0

我是 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

有谁知道是什么问题?

谢谢

4

1 回答 1

2

这个错误对我来说很清楚:

用户 'IIS APPPOOL\DefaultAppPool' 登录失败,位于DbConnectionPool.GetConnection

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

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

于 2012-10-22T08:38:44.777 回答