473,402 Members | 2,053 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,402 software developers and data experts.

Access to the Request object in System.Web.UI.Page derivative...

namespace CIBWeb
{
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
}

protected override void OnInit(EventArgs e)
{
THIS NEXT LINE THROWS EXCEPTION ALSO, CANNOT USE
HttpContext.Current.Request.QueryString["sc"] != string .Empty
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?
Nov 18 '05 #1
2 1691
I believe your problem exists when you have no cookie / querystring present.
You can also perform other checks like HasKeys or Count.
Try retrieving your values with a helper method:

public string getCookie(string strCookie)
{
string cookieValue="";
try
{
cookieValue= Request.Cookies[strCookie].Value;
}
catch(Exception)
{
cookieValue="No Value";
}
return cookieValue;
}

Response.Write(getCookie("source_code"));

-Brian K. Williams

"Terry Mulvany" <te****@mcelroyla.com> wrote in message
news:eW**************@TK2MSFTNGP09.phx.gbl...
namespace CIBWeb
{
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
}

protected override void OnInit(EventArgs e)
{
THIS NEXT LINE THROWS EXCEPTION ALSO, CANNOT USE
HttpContext.Current.Request.QueryString["sc"] != string .Empty
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?

Nov 18 '05 #2
Thanks. I had an epiphany and fixeed this about half an hour ago.
I am just testing for null first.

"Brian K. Williams" <wi*******@millenia.com> wrote in message
news:u0**************@TK2MSFTNGP10.phx.gbl...
I believe your problem exists when you have no cookie / querystring present. You can also perform other checks like HasKeys or Count.
Try retrieving your values with a helper method:

public string getCookie(string strCookie)
{
string cookieValue="";
try
{
cookieValue= Request.Cookies[strCookie].Value;
}
catch(Exception)
{
cookieValue="No Value";
}
return cookieValue;
}

Response.Write(getCookie("source_code"));

-Brian K. Williams

"Terry Mulvany" <te****@mcelroyla.com> wrote in message
news:eW**************@TK2MSFTNGP09.phx.gbl...
namespace CIBWeb
{
public class BasePage : System.Web.UI.Page
{
public BasePage()
{
}

protected override void OnInit(EventArgs e)
{
THIS NEXT LINE THROWS EXCEPTION ALSO, CANNOT USE
HttpContext.Current.Request.QueryString["sc"] != string .Empty
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?


Nov 18 '05 #3

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

Similar topics

1
by: Theerachet Pratoommanee | last post by:
This is error message I've got. Any suggestion would be appreciated. Server Error in '/WebDirectory' Application. ----------------------------------------------------------------------------...
1
by: Ben Pryhoda | last post by:
I have already used a third party com object in my code, and it went easily. Add the reference, call the methods, and get my results. But I am integrating a legacy com object and I follow the...
2
by: Brent Burkart | last post by:
I am trying to send an email using SMTP server through IIS. I am recieving the following error. Access is denied. Description: An unhandled exception occurred during the execution of the...
2
by: Chuck Ritzke | last post by:
Hi all, I am getting an intermittant error after uploading a project from my development machine. I click on a link which opens an aspx page that, upon page load, reads a very small amount of...
1
by: Rico | last post by:
I have tried to access a database using asp.net. after some entries like 120+, I got an unspecified error message. Anyone know what is happening, it seems to be stuck at the same line even when i...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
1
by: cpajoe2001 | last post by:
I am having an issue and after searching around online for a day and half now and finding others with the same problem but yet no solution to my issue I am looking for help. What i have is ServerA...
1
by: karthi84 | last post by:
hi, when i tried to open a new excel spread sheet from my web form i got this access denied page. can any one help me in solving this problem. Server Error in '/sk/ContractInvoice'...
0
by: yukijocelyn | last post by:
I have experienced a problem here while doing a form for accessing datadbase using MS Access. I'm using the AccessDataSource control, and using Gridview to pull the data from the database. I am able...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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
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
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
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...
0
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,...
0
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...

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.