473,569 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("emp id"
ds.Tables(0).Ro ws(0).Item(0))
Dim FnameCookie As New HttpCookie("emp name"
ds.Tables(0).Ro ws(0).Item(1))
Response.Cookie s.Add(IdCookie)
Response.Cookie s.Add(FnameCook ie)

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

If Request.Cookies ("empid").Va lue = "" 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.NullRefe renceException: 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.EventArg s) Handles MyBase.Load
Line 25: Dim id As String
Line 26: id = Request.Cookies ("empid").Va lue
Line 27: 'If CType(Response. Cookies("empid" ).Value, String)
"" Then
Line 28:
Source File: c:\inetpub\wwwr oot\Gotsap\emph ome.aspx.vb Line: 26

Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of a
object.]
Gotsap.emphome. Page_Load(Objec t sender, EventArgs e) i
c:\inetpub\wwwr oot\Gotsap\emph ome.aspx.vb:26
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +731


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.432 2.573
ASP.NET Version:1.1.432 2.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 1784
Where are you setting the following:

Dim IdCookie As New HttpCookie("emp id",
ds.Tables(0).Ro ws(0).Item(0))
Dim FnameCookie As New HttpCookie("emp name",
ds.Tables(0).Ro ws(0).Item(1))
Response.Cookie s.Add(IdCookie)
Response.Cookie s.Add(FnameCook ie)

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("emp id",
ds.Tables(0).Ro ws(0).Item(0))
Dim FnameCookie As New HttpCookie("emp name",
ds.Tables(0).Ro ws(0).Item(1))
Response.Cookie s.Add(IdCookie)
Response.Cookie s.Add(FnameCook ie)

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

If Request.Cookies ("empid").Va lue = "" 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.NullRefe renceException: 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.EventArg s) Handles MyBase.Load
Line 25: Dim id As String
Line 26: id = Request.Cookies ("empid").Va lue
Line 27: 'If CType(Response. Cookies("empid" ).Value, String) =
"" Then
Line 28:
Source File: c:\inetpub\wwwr oot\Gotsap\emph ome.aspx.vb Line: 26

Stack Trace:
[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Gotsap.emphome. Page_Load(Objec t sender, EventArgs e) in
c:\inetpub\wwwr oot\Gotsap\emph ome.aspx.vb:26
System.Web.UI.C ontrol.OnLoad(E ventArgs e) +67
System.Web.UI.C ontrol.LoadRecu rsive() +35
System.Web.UI.P age.ProcessRequ estMain() +731


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.432 2.573;
ASP.NET Version:1.1.432 2.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
23288
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 The problem I am having is that each time I reload the same PHP page, I get
8
3960
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
2221
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 production box. On the dev box everything works fine, in production it hoses: One of the things a user can do is click a "Change region" link which...
1
3325
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 following error-message: ************** Compile error: Function of interface marked as restricted, or the function uses an
3
2391
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 to one web-server/same IP, they just have different applications configured in IIS. I've created an authentication cookie, where a master user can...
4
4967
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. The server then writes a result cookie into the content destined for the IFRAME. I am having issues accessing the cookie. If I use a debuger I...
0
973
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. But as soon as I log on to the other site, on the first site system logs me off. Thes are my settings: System : WinXP, .NET1.1, ASP.NET with VB.NET,...
0
2251
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 updating the code-behind dll) accessing any aspx page in the application causes the application to run for the first time. Some of the initialization...
0
251
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 HttpCookie("empname" ds.Tables(0).Rows(0).Item(1)) Response.Cookies.Add(IdCookie) Response.Cookies.Add(FnameCookie)
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6286
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5222
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3656
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.