Trouble with session

Discussion in 'ASP .Net Web Services' started by Shawn, Feb 10, 2004.

  1. Shawn

    Shawn Guest

    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
    Shawn, Feb 10, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hypo
    Replies:
    6
    Views:
    394
  2. Greg Linwood

    Trouble with using Session state

    Greg Linwood, Nov 22, 2003, in forum: ASP .Net
    Replies:
    9
    Views:
    1,198
    Greg Linwood
    Nov 22, 2003
  3. Jeff Smythe
    Replies:
    3
    Views:
    1,227
    Jeff Smythe
    Jan 2, 2004
  4. =?Utf-8?B?Um9iSEs=?=
    Replies:
    4
    Views:
    5,253
    =?Utf-8?B?Um9iSEs=?=
    Apr 11, 2007
  5. Jazzis
    Replies:
    2
    Views:
    234
    Jazzis
    Sep 23, 2003
Loading...

Share This Page