473,498 Members | 1,776 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

System.Web.UI.Page derivative...

I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all
my pages inherit from. I need to set some properties (either in the OnInit
or constructor) based on a potential Request.Cookie or a name/value pair in
Request.QueryString.
But I am getting a
'System.NullReferenceException: Object reference not set to an instance of
an object.'
error when I try to view any aspx derived from this BasePage.
I am using HttpContext.Current.Request.Cookies as well as for the
QueryString but still get this error.
Any ideas!?

Thank you.
Nov 18 '05 #1
4 5081
Are you using Request.QueryString.Get("name").Value?

-Brian K. Williams

"Terry Mulvany" <te****@mcelroyla.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all
my pages inherit from. I need to set some properties (either in the OnInit or constructor) based on a potential Request.Cookie or a name/value pair in Request.QueryString.
But I am getting a
'System.NullReferenceException: Object reference not set to an instance of
an object.'
error when I try to view any aspx derived from this BasePage.
I am using HttpContext.Current.Request.Cookies as well as for the
QueryString but still get this error.
Any ideas!?

Thank you.

Nov 18 '05 #2
What is the line of code that is throwing this exception? There is an object
reference in that line that is not initialized or is null for some reason.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Terry Mulvany" <te****@mcelroyla.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all
my pages inherit from. I need to set some properties (either in the OnInit or constructor) based on a potential Request.Cookie or a name/value pair in Request.QueryString.
But I am getting a
'System.NullReferenceException: Object reference not set to an instance of
an object.'
error when I try to view any aspx derived from this BasePage.
I am using HttpContext.Current.Request.Cookies as well as for the
QueryString but still get this error.
Any ideas!?

Thank you.

Nov 18 '05 #3
To be more specific...
namespace CIBWeb
{
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
}

protected override void OnInit(EventArgs e)
{
if (
HttpContext.Current.Request.Cookies["source_code"].Value.ToString() !=
string.Empty )
{
...
}
...
}
}
}

YIELDS THIS ERROR ...
Server Error in '/CIBWeb' Application.
----------------------------------------------------------------------------
----

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 64: // no other source code overrides it. ex: user clicks url in
email (email campaign) and then once on the site clicks on a ad banner
(which has
Line 65: // it's own source code), the first source code should still be
the one used
Line 66: if (
HttpContext.Current.Request.Cookies["source_code"].Value.ToString() !=
string.Empty )
Line 67: {
Line 68: SourceCode =
HttpContext.Current.Request.Cookies["source_code"].Value.ToString();
Source File: c:\inetpub\wwwroot\cibweb\src\basepage.cs Line: 66

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
CIBWeb.BasePage.OnInit(EventArgs e) in
c:\inetpub\wwwroot\cibweb\src\basepage.cs:66
CIBWeb.HealthWellness._Default.OnInit(EventArgs e) in
c:\inetpub\wwwroot\CIBWeb\HealthWellness\Default.a spx.cs:74
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Page.ProcessRequestMain()

ANY IDEAS?
"Kevin Spencer" <ke***@takempis.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
What is the line of code that is throwing this exception? There is an object reference in that line that is not initialized or is null for some reason.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Terry Mulvany" <te****@mcelroyla.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all my pages inherit from. I need to set some properties (either in the

OnInit
or constructor) based on a potential Request.Cookie or a name/value pair

in
Request.QueryString.
But I am getting a
'System.NullReferenceException: Object reference not set to an instance of an object.'
error when I try to view any aspx derived from this BasePage.
I am using HttpContext.Current.Request.Cookies as well as for the
QueryString but still get this error.
Any ideas!?

Thank you.


Nov 18 '05 #4
To be more specific...
namespace CIBWeb
{
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
}

protected override void OnInit(EventArgs e)
{
if (
HttpContext.Current.Request.Cookies["source_code"].Value.ToString() !=
string.Empty )
{
...
}
...
}
}
}

YIELDS THIS ERROR ...
Server Error in '/CIBWeb' Application.
----------------------------------------------------------------------------
----

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 64: // no other source code overrides it. ex: user clicks url in
email (email campaign) and then once on the site clicks on a ad banner
(which has
Line 65: // it's own source code), the first source code should still be
the one used
Line 66: if (
HttpContext.Current.Request.Cookies["source_code"].Value.ToString() !=
string.Empty )
Line 67: {
Line 68: SourceCode =
HttpContext.Current.Request.Cookies["source_code"].Value.ToString();
Source File: c:\inetpub\wwwroot\cibweb\src\basepage.cs Line: 66

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
CIBWeb.BasePage.OnInit(EventArgs e) in
c:\inetpub\wwwroot\cibweb\src\basepage.cs:66
CIBWeb.HealthWellness._Default.OnInit(EventArgs e) in
c:\inetpub\wwwroot\CIBWeb\HealthWellness\Default.a spx.cs:74
System.Web.UI.Control.InitRecursive(Control namingContainer)
System.Web.UI.Page.ProcessRequestMain()

ANY IDEAS?
"Brian K. Williams" <wi*******@millenia.com> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
Are you using Request.QueryString.Get("name").Value?

-Brian K. Williams

"Terry Mulvany" <te****@mcelroyla.com> wrote in message
news:Oi**************@TK2MSFTNGP09.phx.gbl...
I have a 'BasePage' (BasePage.cs) derived from System.Web.UI.Page that all my pages inherit from. I need to set some properties (either in the

OnInit
or constructor) based on a potential Request.Cookie or a name/value pair

in
Request.QueryString.
But I am getting a
'System.NullReferenceException: Object reference not set to an instance of an object.'
error when I try to view any aspx derived from this BasePage.
I am using HttpContext.Current.Request.Cookies as well as for the
QueryString but still get this error.
Any ideas!?

Thank you.


Nov 18 '05 #5

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

Similar topics

12
2809
by: David B. Bitton | last post by:
I'm experiencing odd behavior on the part of the XMLSerializer. I'm deserializing an XmlNode. The XmlNode is pass as part of a call to IConfigurationSectionHandler.Create. My XML looks like: ...
2
1694
by: Terry Mulvany | last post by:
namespace CIBWeb { public class BasePage : System.Web.UI.Page { public BasePage() { } protected override void OnInit(EventArgs e) {
4
3628
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed...
3
1875
by: xhunga | last post by:
Hello, This time I try to simulate the derivative of a product. Into a text file, I have an equation of this type. I have created these equations with the previous functions. Examples:
0
1480
by: xhunga | last post by:
Symbolic computation : the derivative of a quotient. Hello, This time I try to simulate the derivative of a quotient. The same function use the quotient rule if it is a quotient (f/g) and the...
9
3009
by: Xah Lee | last post by:
REQUIREMENTS FOR A VISUALIZATION SOFTWARE SYSTEM FOR 2010 Xah Lee, 2007-03-16 In this essay, i give a list of requirements that i think is necessary for a software system for creating...
10
8806
by: DDCane | last post by:
i have made a code for finding a derivative and now im trying to use it to help me with a code for the newton raphson method: def derivative (f,x,h): import math return float(1/(2*h)) *...
3
1509
by: jlynx23 | last post by:
gud am...i am currently working with a project of mine which is about derivative...and i am having some problem with the printing of the derivative... here is the block of code i used: /* print...
6
14972
by: knielsen73 | last post by:
Hi, I am looking to do a simple derivative. I would expect such a function to be available in numpy, but can't find it. I have written my own, but just curious if anybody knows of such function...
0
7004
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
7208
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...
1
6890
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...
1
4915
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
3095
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
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1423
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 ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.