cookies creating object reference errors

L

lacanela

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

If CInt(Request.QueryString("affid")) > 0 Then
Dim affcookie As HttpCookie
affcookie = New HttpCookie("affidcookie", CInt
(Request.QueryString("affid")))
affCookie.Expires = Now().AddDays(30)
Response.Cookies.Add(affCookie)
Session("affID") = CInt(Request.QueryString("affid"))
Else
If Request.Cookies.Count = 1 Then
Session("affID") = 0
Else
Session("affID") = CInt(Request.Cookies
("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.NullReferenceException: Object reference not
set to an instance of an object."

What am I missing here?

Any advice will be greatly appreciated. Thanks

Trym
 

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

Top