cookies creating object reference errors

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lacanela

    cookies creating object reference errors

    Since I want to use cookies on a site running asp.net 1.1. I have
    added the following code:

    If CInt(Request.Qu eryString("affi d")) 0 Then
    Dim affcookie As HttpCookie
    affcookie = New HttpCookie("aff idcookie", CInt
    (Request.QueryS tring("affid")) )
    affCookie.Expir es = Now().AddDays(3 0)
    Response.Cookie s.Add(affCookie )
    Session("affID" ) = CInt(Request.Qu eryString("affi d"))
    Else
    If Request.Cookies .Count = 1 Then
    Session("affID" ) = 0
    Else
    Session("affID" ) = CInt(Request.Co okies
    ("affidcookie") .Value)
    End If
    End If

    The idea is that if there is a querystring in the url of the page then
    the value of the string is stored as cookie and used as in the current
    session as well. Otherwise, the code tests for existing cookies.

    Running it locally, everything works fine, but when I upload to the
    web server I get the following error:

    "Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.

    Exception Details: System.NullRefe renceException: Object reference not
    set to an instance of an object."

    What am I missing here?

    Any advice will be greatly appreciated. Thanks

    Trym
  • lacanela

    #2
    Re: cookies creating object reference errors

    More info on this issue: If I clear the cache of my browser it works.

    On Nov 19, 1:41 am, lacanela <hotellacan...@ gmail.comwrote:
    Since I want to use cookies on a site running asp.net 1.1. I have
    added the following code:
    >
    If CInt(Request.Qu eryString("affi d")) 0 Then
                Dim affcookie As HttpCookie
                affcookie = New HttpCookie("aff idcookie", CInt
    (Request.QueryS tring("affid")) )
                affCookie.Expir es = Now().AddDays(3 0)
                Response.Cookie s.Add(affCookie )
                Session("affID" ) = CInt(Request.Qu eryString("affi d"))
    Else
                If Request.Cookies .Count = 1 Then
                    Session("affID" ) = 0
                Else
                    Session("affID" ) = CInt(Request.Co okies
    ("affidcookie") .Value)
                End If
    End If
    >
    The idea is that if there is a querystring in the url of the page then
    the value of the string is stored as cookie and used as in the current
    session as well. Otherwise, the code tests for existing cookies.
    >
    Running it locally, everything works fine, but when I upload to the
    web server I get the following error:
    >
    "Object reference not set to an instance of an object.
    Description: An unhandled exception occurred during the execution of
    the current web request. Please review the stack trace for more
    information about the error and where it originated in the code.
    >
    Exception Details: System.NullRefe renceException: Object reference not
    set to an instance of an object."
    >
    What am I missing here?
    >
    Any advice will be greatly appreciated. Thanks
    >
    Trym

    Comment

    Working...