Trouble with session

S

Shawn

Hi.
I have a webservice with a couple of methods. One of them is a login
function where I validate the user and send back a key (in the form of a
Guid). The user must then supply this key when he calls one of my other
methods so that I know that he has been validated. I'm trying to store this
key in session on the webservice, but I get an error.
Here is a simplified version of my code:

<WebMethod(EnableSession:=True)> Public Function Login(ByVal Username As
String, ByVal Password As String, ByVal Domain As Integer) As Guid
If Username = "xxx" And Password = "xxx" And Domain = 999 Then
Session("guidToken") = guid.NewGuid()
Return Session("guidToken")
Else
Throw New Security.SecurityException()
End If
End Function

<WebMethod(EnableSession:=True)> Public Function ReadXML(ByVal
guidLoginToken As Guid) As Byte()
'Check that the user is logged in.
If Not guidLoginToken.ToString = Session("guidToken").ToString Then
Throw New MethodAccessException()
End If
......
....
End Function

I'm getting the error when I call the ReadXML function. "Object reference
not set to an instance of an object". The error occurs at this line: "If
Not guidLoginToken.ToString = Session("guidToken").ToString Then"

Any ideas?

Thanks,
Shawn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top