473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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.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
Nov 19 '08 #1
1 2008
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.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
Nov 20 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
0
by: Pat Allan | last post by:
I've spent half a day on this with no success, so I'm hoping someone can point out what I'm doing wrong. I have an ASP.NET Server-side component that I've created, and as part of its Render...
2
by: Scott | last post by:
I would like to have my ASPX page call a function intended to make changes the the current Page.Response.Cookies. I had thought that to allow the function to modify the Cookies, I would have top...
2
by: Ersin Gençtürk | last post by:
hi , I am trying to add a usercontrol to the control collection of a webcontrol but I get "Object reference not set to an instance of an object." errors.On the other hand , by changing the code...
4
by: lalitha1024 | last post by:
Hi, In my Asp.net project when i am login to my site, i'll set th cookies by using below commands. Dim IdCookie As New HttpCookie("empid" ds.Tables(0).Rows(0).Item(0)) Dim FnameCookie As New...
4
by: Water Cooler v2 | last post by:
I am practicing Cookies in .NET. Its working fine but when I want to clear my cookies, the statement, Response.Cookies.Clear does not work. What gives? Here's what I do:
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
0
by: dawson | last post by:
I started off by trying to use the HttpCapabilitiesBase.Cookies Property (Note: This property is new in the .NET Framework version 2.0) however it kept on returning true even when I disabled...
7
by: André | last post by:
Hi, I need several cookies depending of an variable (x), so i defined a HttpCookie() as an array. My problems: 1)I get the error: Object reference not set to an instance of an object. 2)My...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.