Problem with accessing function in pageload method
|
.NET Framework 2.0For discussion of the Microsoft .NET Framework 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the .NET Framework 2.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Problem with accessing function in pageload method
Hi All,
I am having a problem with accesing function in the page. i have a page say user.aspx in the page load method
i am calling function to validate the user.
it works fine when single user access the page but when another user try to access the page then it crash the
first users processing and empty the session variable.
means when i am calling function in the page load of user.aspx then it is giving me problem.
and if i write user validation code direct in page load method then it works fine.
problem occurs only when i write user validation code in function and try to call that function in page load of
user.aspx
Private Sub Page_Load
IF validateUser() THEN
Response.write ("Welcome" & sUserID )
Else
Response.Redirect("UserNotFound.aspx?userid=" & sUserID & "&Form=DataXS")
End If
End sub
Public Function validateUser() as boolean
Dim dbOleDbDataReader As OleDbDataReader
dim bflag as boolen
sSQL = "Select NAME From kuaf where lower(NAME)='" & LCase(sUserID) & "'
Dim sConnectionString As String = xsData.getDatabaseConnection(sLogFile)
Using dbConnection As New OleDbConnection(sConnectionString)
Dim dbcommand As New OleDbCommand(sSQL, dbConnection)
dbcommand.CommandType = CommandType.Text
dbcommand.Connection.Open()
dbOleDbDataReader = dbcommand.ExecuteReader()
If Not dbOleDbDataReader Is Nothing Then
If dbOleDbDataReader.Read() Then
bflag = True
Else
Response.Redirect("UserNotFound.aspx?userid=" & sUserID & "&Form=DataXS")
End If
End If
dbOleDbDataReader.Close()
dbOleDbDataReader = Nothing
dbcommand.Dispose()
dbcommand = Nothing
dbConnection.Close()
End Using
Dim sUserID As String = Request.ServerVariables("LOGON_USER").Substring(Re quest.ServerVariables("LOGON_USER").IndexOf("\") + 1)
and after user validation user goes to another pages and start processing like
accesssing reports and all but when another user try to access the page the it
crash the application and kill the first user session and
throws error like:
Thread abort exception: 'thread has been aborted. '
In other pages which first user access i m using thread for processing.
But when i write the User validation code in page laod method then it works fine
it dosent crash the first user and dosent kill the session also.
i can write the code in page load method but i have some other function also
which i am calling many times in page load method. if i will write the same code that many time then no use of writing functions.