473,387 Members | 1,597 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,387 software developers and data experts.

Problem with accessing cookies?


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 HttpCookie("empname"
ds.Tables(0).Rows(0).Item(1))
Response.Cookies.Add(IdCookie)
Response.Cookies.Add(FnameCookie)

In each and every page i wrote authorization by using belo
statements.

If Request.Cookies("empid").Value = "" Then
Response.Write("<b> You are not authorised to view thi
page...</b>")
Server.Transfer("employerlogin.aspx")
End If

when i am trying to execute pages separetely in browser i am gettin
below error. i am copying here my total error page.

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

Exception Details: System.NullReferenceException: Object reference no
set to an instance of an object.

Source Error:
Line 24: Private Sub Page_Load(ByVal sender As System.Object, ByVa
e As System.EventArgs) Handles MyBase.Load
Line 25: Dim id As String
Line 26: id = Request.Cookies("empid").Value
Line 27: 'If CType(Response.Cookies("empid").Value, String)
"" Then
Line 28:
Source File: c:\inetpub\wwwroot\Gotsap\emphome.aspx.vb Line: 26

Stack Trace:
[NullReferenceException: Object reference not set to an instance of a
object.]
Gotsap.emphome.Page_Load(Object sender, EventArgs e) i
c:\inetpub\wwwroot\Gotsap\emphome.aspx.vb:26
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573
ASP.NET Version:1.1.4322.573

What is the error, i am not able to understand.

Plz help me out.

Thanks in advance.

Lalitha.

--
lalitha102
-----------------------------------------------------------------------
lalitha1024's Profile: http://www.highdots.com/forums/member.php?userid=47
View this thread: http://www.highdots.com/forums/showthread.php?t=218585

Nov 19 '05 #1
4 1759
Where are you setting the following:

Dim IdCookie As New HttpCookie("empid",
ds.Tables(0).Rows(0).Item(0))
Dim FnameCookie As New HttpCookie("empname",
ds.Tables(0).Rows(0).Item(1))
Response.Cookies.Add(IdCookie)
Response.Cookies.Add(FnameCookie)

Is this in Page_Load or is it in Global? It seems on the face of it
you're trying to use a Cookie that doesn't exist. Hence the
NullReference exception. If you could share emphome.aspx.cs that would
be helpful as well.

Clint Hill
H3O Software
http://www.h3osoftware.com

lalitha1024 wrote:
Hi,
In my Asp.net project when i am login to my site, i'll set the
cookies by using below commands.

Dim IdCookie As New HttpCookie("empid",
ds.Tables(0).Rows(0).Item(0))
Dim FnameCookie As New HttpCookie("empname",
ds.Tables(0).Rows(0).Item(1))
Response.Cookies.Add(IdCookie)
Response.Cookies.Add(FnameCookie)

In each and every page i wrote authorization by using below
statements.

If Request.Cookies("empid").Value = "" Then
Response.Write("<b> You are not authorised to view this
page...</b>")
Server.Transfer("employerlogin.aspx")
End If

when i am trying to execute pages separetely in browser i am getting
below error. i am copying here my total error page.

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.

Source Error:
Line 24: Private Sub Page_Load(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles MyBase.Load
Line 25: Dim id As String
Line 26: id = Request.Cookies("empid").Value
Line 27: 'If CType(Response.Cookies("empid").Value, String) =
"" Then
Line 28:
Source File: c:\inetpub\wwwroot\Gotsap\emphome.aspx.vb Line: 26

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Gotsap.emphome.Page_Load(Object sender, EventArgs e) in
c:\inetpub\wwwroot\Gotsap\emphome.aspx.vb:26
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.573;
ASP.NET Version:1.1.4322.573

What is the error, i am not able to understand.

Plz help me out.

Thanks in advance.

Lalitha.C

Nov 19 '05 #2

Hi,
i am new to asp.net. i am setting cookies in the login page, afte
successful login means in the submit button click.
any other way to set cookies and plz help to solve my problem.
i am very sorry to say like that, i am not able to understand belo
words
"If you could share emphome.aspx.cs that would be helpful as well"
can you plz explain detaild.

thanking you,

Lalitha.

--
lalitha102
-----------------------------------------------------------------------
lalitha1024's Profile: http://www.highdots.com/forums/member.php?userid=47
View this thread: http://www.highdots.com/forums/showthread.php?t=218585

Nov 19 '05 #3

Hi,
i am new to asp.net. i am setting cookies in the login page, afte
successful login means in the submit button click.
any other way to set cookies and plz help to solve my problem.
i am very sorry to say like that, i am not able to understand belo
words
"If you could share emphome.aspx.cs that would be helpful as well"
can you plz explain detaild.

thanking you,

Lalitha.

--
lalitha102
-----------------------------------------------------------------------
lalitha1024's Profile: http://www.highdots.com/forums/member.php?userid=47
View this thread: http://www.highdots.com/forums/showthread.php?t=218585

Nov 19 '05 #4
I was asking you to share the code that sets the cookie. It is likely in
the emphome.aspx.vb file (codebehind). That is where the stack trace
showed the exception.

lalitha1024 wrote:
Hi,
i am new to asp.net. i am setting cookies in the login page, after
successful login means in the submit button click.
any other way to set cookies and plz help to solve my problem.
i am very sorry to say like that, i am not able to understand below
words
"If you could share emphome.aspx.cs that would be helpful as well",
can you plz explain detaild.

thanking you,

Lalitha.C


--
Clint Hill
H3O Software
http://www.h3osoftware.com
Nov 19 '05 #5

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

Similar topics

13
by: Mimi | last post by:
Hello, I am having trouble using the session vars in PHP 4.3.9 OS: Win XP Prof Web Server IIS (is local and there are no links to other servers from the web pages I work on) Browser: IE 6.0 ...
8
by: ndsoumah | last post by:
hello guys I'm trying to get access to variables I put in a session variable from another page and it fails... here's the exact situation main file page1.php
1
by: Tony Archer | last post by:
(Forgive the dupicate post, I had left out the OS Version out of the prior post.) Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a...
1
by: Martin Emanuelsson | last post by:
Hello! I'm having a problems when trying to make a DLL in VB6. The code is using ScriptingContext to access the Cookies-collection from the asp-pages, but when I try making the DLL I get the...
3
by: Raterus | last post by:
Hello, I've got a bunch of web-portals that customers use to log-in and see their data. In a production environment, each of these has a completely different domain name, but they all point back...
4
by: Paul Brant | last post by:
Hi all, I have a page with an IFRAME in it. From a script in the main ( parent ) page I instruct the IFRAME to load a specific URL. The URL contains parameters that are processed by the server....
0
by: Ing. Rajesh Kumar | last post by:
Hi everybody I have two local sites on my local machine. Both ask the user to log in and also have an option to remember the user. If i work only with one of these sites, everything works fine....
0
by: Joergen Bech | last post by:
Fairly new to ASP.NET 1.1. Getting the error below when running application on a web server outside of my control, but only the first time I run it: 1. After a long period of inactivity (or...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.