Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > .NET 2.0 and Visual Studio. 2005 > .NET Framework 2.0
|
.NET Framework 2.0 For 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
 
Old September 8th, 2008, 05:19 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default 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

    Return bflag

 End Function

 can u tell me why it is happening..

 Thanks
 -Nelly

 
Old September 8th, 2008, 05:44 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

What is sUserID and where is it set?

Also, when you say 'gives me problem' what do you mean? Does it throw an Exception? Does the page fail to load? What exactly happens?

/- Sam Judson : Wrox Technical Editor -/
 
Old September 8th, 2008, 06:13 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default

In the page load setting the sUserId variable :

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.

-nelly


 
Old September 8th, 2008, 06:19 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Well then, your error isn't in this page, but your use of Threads in the other page, as the error is thread related.

Generally Threads in web applications are a very bad idea.

/- Sam Judson : Wrox Technical Editor -/
 
Old September 8th, 2008, 06:45 AM
Authorized User
 
Join Date: Apr 2008
Posts: 85
Thanks: 10
Thanked 0 Times in 0 Posts
Default

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.

-nelly



 
Old September 8th, 2008, 06:49 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Can you show us the same code in the Page_Load event then - there is obviously some difference between the two else it would work.

/- Sam Judson : Wrox Technical Editor -/





Similar Threads
Thread Thread Starter Forum Replies Last Post
accessing elements using document() function geoGregory3 XSLT 2 February 28th, 2008 07:39 PM
Method 'Range' of _Global' Failed accessing Excel Socko Beginning VB 6 0 January 29th, 2008 09:33 AM
Accessing a VBA module's method from VBScript hamffjs Access VBA 3 November 28th, 2006 09:27 AM
diff. between function and method venkata C# 1 May 11th, 2006 01:47 PM
Accessing all the webforms with a function lily611 General .NET 5 June 21st, 2004 05:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.