473,486 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Request.Cookies("Email").Value

I cannot believe that this code causes an error:

Dim MyCookie as string = Request.Cookies("Email").Value

Object reference not set to an instance of an object.

If the cookie is found, it works, if the cookie is not found, the error
above is triggered. and i can't just do this:

Dim MyCookie as string = Request.Cookies("Email")

Value of type 'System.Web.HttpCookie' cannot be converted to 'String'.

So, how do you check for cookies? Keeping in mind that the cookie may
exist, or not...

Thanks.

Jul 21 '05 #1
3 4566
> I cannot believe that this code causes an error:

Dim MyCookie as string = Request.Cookies("Email").Value

Object reference not set to an instance of an object.

I don't know about VB but maybe something like this (pseude code but you get
the idea).

if (Request.Cookies("Email")!=NULL) {
string = Request.Cookies("Email").Value
}

Jul 21 '05 #2

"Olaf Baeyens"
I don't know about VB but maybe something like this (pseude code but you
get
the idea).

if (Request.Cookies("Email")!=NULL) {
string = Request.Cookies("Email").Value
}


If Not Request.Cookies("Email") Is Nothing then
dim mycookie as string = Request.Cookies("Email").Value
End if

Cor
Jul 21 '05 #3
If Not Request.Cookies("Email") Is Nothing then
dim mycookie as string = Request.Cookies("Email").Value
End if

Nice and now try to avoid to request 2 times. ;-)
Jul 21 '05 #4

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

Similar topics

8
2204
by: Sam Sungshik Kong | last post by:
Hello! I use Python for ASP programming. I found something weird. Response.Write(Request("something")) It draws "None" when there's no value for something. Actually I expect "" instead of...
5
1719
by: Peter Clark | last post by:
Think of something like MyYahoo: a personalized portal with news aggregator, weather forecast, comics, etc. Now instead of visiting a web site, think of all of it being sent daily as an email. It...
2
6126
by: Hugh Welford | last post by:
Hi I cant seem to get the LIKE oprator to work in asp. I am trying to verify e-mail input format by using request("email") like "*@*.*" but it returns "sub or function not defined" any...
0
1279
by: Hardy Wang | last post by:
Hi, I have an application which encrypts some certian link to format like:...
3
321
by: tascien | last post by:
I cannot believe that this code causes an error: Dim MyCookie as string = Request.Cookies("Email").Value Object reference not set to an instance of an object. If the cookie is found, it...
3
3353
by: Mange | last post by:
I'm using WebRequest class to access a PHP script, but keep getting a 400 error from the server when calling the GetResponse() method. I have added the url to the script in the bypass list in...
23
2845
by: codefire | last post by:
Hi, I am trying to get a regexp to validate email addresses but can't get it quite right. The problem is I can't quite find the regexp to deal with ignoring the case james..kirk@fred.com, which...
1
6434
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
3
2430
by: MrCorbeaux | last post by:
My "Email a Webpage" form works find except when the end user receives the email, the URL is text only and not a hyperlink. The "Email a Page" form calls the URL from the previous page using: ...
0
7099
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7175
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7319
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5430
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4864
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4559
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3069
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.