美好的一天,我是.net编程的新手,也是IIS Web部署配置。
目前,我有一个在IIS上使用Framework 4.5运行的asp.net应用程序。对于在服务器上部署应用程序的第一个月,它运行良好且流畅。但是,最近应用程序存在登录页面实际加载的问题,但是当用户键入其凭据时,页面加载计时器将显示并消失,使用户搁浅,无法登录。
此外,服务器已经过如下所述的安全程序:
此外,该应用程序的架构是:
因此,连接实际上是跨服务器进行的,登录身份验证实际上是针对 Active Directory 进行身份验证的。
附上截图: Unhandled exception screenshot
在事件查看器上进行检查后,发现以下警告可能表明该问题有所不同:
Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 1/18/2015 5:27:15 PM
Event time (UTC): 1/18/2015 9:27:15 AM
Event ID: 2ac169fff7284e86b7b0844e5d9ccab1
Event sequence: 4
Event occurrence: 1
Event detail code: 0
Application information:
Application domain: /LM/W3SVC/1/ROOT/AML-1-130660468323976167
Trust level: Full
Application Virtual Path: /AML
Application Path: D:\AML\
Machine name: AMLWEB
Process information:
Process ID: 6756
Process name: w3wp.exe
Account name: IIS APPPOOL\.NET v4.5
Exception information:
Exception type: InvalidOperationException
Exception message: The ConnectionString property has not been initialized.
at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.DBManager.OpenConnection(String DBStrConn, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 50
at DBManager.DBManager.ExecuteSQLQuery_ReturnDS(String& ReturnErrorMsg, String SqlString, String DBConnString, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 190
at SQLAdminQueryManager.AdminQueryManager.AdminQueryManager_Staff_Login.Staff_Login_Retreive(cor_staff AppEntity, String DbSQLConnString, String DbType, String& ReturnErrorMsg, Object& ReturnObjDataset, String AccessType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\SQLAdminQueryManager\AdminQueryManager.vb:line 65
at Login_page_LDAP_Code.LoginButton_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Request information:
Request URL: https://amlweb/AML/Login_page.aspx
Request path: /AML/Login_page.aspx
User host address: 10.1.67.61
User:
Is authenticated: False
Authentication Type:
Thread account name: IIS APPPOOL\.NET v4.5
Thread information:
Thread ID: 10
Thread account name: IIS APPPOOL\.NET v4.5
Is impersonating: False
Stack trace: at System.Data.SqlClient.SqlConnection.PermissionDemand()
at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at DBManager.DBManager.OpenConnection(String DBStrConn, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 50
at DBManager.DBManager.ExecuteSQLQuery_ReturnDS(String& ReturnErrorMsg, String SqlString, String DBConnString, Int16 DBType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\DBManager\DBManager.vb:line 190
at SQLAdminQueryManager.AdminQueryManager.AdminQueryManager_Staff_Login.Staff_Login_Retreive(cor_staff AppEntity, String DbSQLConnString, String DbType, String& ReturnErrorMsg, Object& ReturnObjDataset, String AccessType) in C:\Users\TESS-HP003\Desktop\AML\ES_Library\SQLAdminQueryManager\AdminQueryManager.vb:line 65
at Login_page_LDAP_Code.LoginButton_Click(Object sender, EventArgs e)
at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Custom event details:
但是,连接字符串确实已正确设置如下:
的Web.config
<connectionStrings>
<add name="AMLDBConnectionString" connectionString="Data Source=AMLDB01, 8001;Initial Catalog=AML_DB;integrated security=true; uid=sa; pwd=p@ssw0rd"/>
</connectionStrings>
它被设置为全局变量:
GlobalSQLConnString = ConfigurationManager.ConnectionStrings("AMLDBConnectionString").ToString
GlobalDBType As Int16 = 1
实际执行以连接到DB的行:
blnReturnValue = objSqlQuery.Staff_Login_Retreive(objBE, GlobalSQLConnString, GlobalDBType, strErrorMsgReturn, returnDS, "S")
调用的方法:
Public Function Staff_Login_Retreive(ByVal AppEntity As BusinessEntities.cor_staff, _
ByVal DbSQLConnString As String, ByVal DbType As String, _
ByRef ReturnErrorMsg As String, ByRef ReturnObjDataset As Object, _
Optional ByVal AccessType As String = "S") As Boolean
With AppEntity
SQlQuery = "SELECT * "
SQlQuery += " FROM cor_staff "
SQlQuery += " WHERE cor_staff.cor_userid =N'" & AppEntity.cor_userid & "'"
End With
'
If AccessType.ToUpper = "R" Then
ReturnObjDataset = ExecuteSQLQuery_ReturnIDR(ReturnErrorMsg, SQlQuery, DbSQLConnString, DbType)
Else
ReturnObjDataset = ExecuteSQLQuery_ReturnDS(ReturnErrorMsg, SQlQuery, DbSQLConnString, DbType)
End If
'
If ReturnErrorMsg.Trim.Length = 0 Then
Return True
Else
Return False
End If
'
End Function
被修改
由于上面的代码实际上会运行并且实际上会在这一行上调用:
ReturnObjDataset = ExecuteSQLQuery_ReturnDS(ReturnErrorMsg, SQlQuery, DbSQLConnString, DbType)
此连接只会在此处打开:
Public Function ExecuteSQLQuery_ReturnDS(ByRef ReturnErrorMsg As String, ByVal SqlString As String, ByVal DBConnString As String, ByVal DBType As Int16) As DataSet
ReturnErrorMsg = ""
Dim DS As New DataSet
'
If DBType = 1 Then
Try
OpenConnection(DBConnString, DBType)
Dim sqlCmd As New SqlCommand(SqlString, sqlConn)
sqlCmd.CommandTimeout = 0
Dim sqlDaAdp As New SqlDataAdapter(sqlCmd)
sqlDaAdp.Fill(DS)
sqlCmd = Nothing
sqlDaAdp = Nothing
CloseConnection(DBType)
Return DS
Catch ex As SqlException
If ex.Number = 18456 Or ex.Number = 4060 Then
ReturnErrorMsg = "Database Connection Error >> Error No : " & ex.Number
Else
ReturnErrorMsg = "SQL Statement Error >> Error No : " & ex.Number
End If
CloseConnection(DBType)
Return Nothing
End Try
ElseIf DBType = 3 Then
Try
OpenConnection(DBConnString, DBType)
Dim oledbCmd As New OleDbCommand(SqlString, oleDbconn)
Dim oledbDaAdp As New OleDbDataAdapter(oledbCmd)
oledbDaAdp.Fill(DS)
oledbDaAdp = Nothing
oledbDaAdp = Nothing
CloseConnection(DBType)
Return DS
Catch ex As OleDbException
If ex.ErrorCode = -2147217887 Then
ReturnErrorMsg = "Database Connection Error >> Error Code : " & ex.ErrorCode
Else
ReturnErrorMsg = "SQL Statement Error >> Error Code : " & ex.ErrorCode
End If
CloseConnection(DBType)
Return Nothing
End Try
End If
'
Return Nothing
'
End Function
打开连接方法:
Public Sub OpenConnection(ByVal DBStrConn As String, ByVal DBType As Int16)
Try
If DBType = 1 Then
sqlConn = New SqlConnection(DBStrConn)
If sqlConn.State = ConnectionState.Closed Then
sqlConn.Open()
Else
sqlConn.Close()
sqlConn.Open()
End If
ElseIf DBType = 3 Then
oleDbconn = New OleDbConnection(DBStrConn)
If oleDbconn.State = ConnectionState.Closed Then
oleDbconn.Open()
Else
oleDbconn.Close()
oleDbconn.Open()
End If
End If
'
Catch ex As Exception
Throw
End Try
End Sub
已编辑部分的结尾
有没有人知道为什么会发生这种异常?
到目前为止,我已完成以下操作以实际尝试调试此问题:
以上都没有奏效。但是当我真正尝试从安全团队的特定楼层访问应用程序时,应用程序实际上开始正常运行,其他人也可以实际访问该应用程序。
请帮助,我完全忘记了这个问题。
是否与我的部署方法,配置或编程有关,我愿意听取建议。
感谢您的时间。