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

URGENT Getting null reference errors on 404??

Hello there,

I'm getting the following error

System.NullReferenceException: Object reference not set to an instance of an
object.

at shopping_bag.GetBagTotals()

which then causes this following error which stops the application pool my
web application is running on

EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4 app_code,
P5 1.0.2587.41853, P6 45c1694a, P7 a6, P8 0, P9
system.nullreferenceexception, P10 NIL.
The GetBagTotals does not have a null reference in it from what I can see. I
only get this error when a visitor hits a page that is non existent, for
example www.domain.com/otherpage.aspx. (recently updated the site so a lot
of pages are no longer there). When these pages are hit I get the following:

Explanation: The Web server connection was closed.
Technical Information (for support personnel)

a.. Error Code 64: Host not available
b.. Background: The connection to the Web server was lost.
And the two errors listed above. I have the 404, 404;2,404;3 in IIS set to
go to an aspx page which works great if someone goes to an .html page that
is no longer available. Weird eh?

So if a user tries to visit a page that is no longer available and it ends
in aspx, they don't get a 404 error, they get what is displayed above and
then a null reference error occurs. If a user tries to visit a page that
ends in .html they get the correct 404 error page and no null errors.

Any ideas why aspx pages are not responding to a 404?

Thanks,

David Lozzi
Feb 1 '07 #1
6 3596
I tried adding

<customErrors mode="RemoteOnly">

<error statusCode="400" redirect="notfound.aspx" />

<error statusCode="401" redirect="notfound.aspx" />

<error statusCode="403" redirect="notfound.aspx" />

<error statusCode="404" redirect="notfound.aspx" />

<error statusCode="408" redirect="notfound.aspx" />

<error statusCode="500" redirect="notfound.aspx" />

<error statusCode="503" redirect="notfound.aspx" />

</customErrors>

To the web.config file and that didn't work either. Still get the previously
stated errors.

I'm sorry, the server is a Win2003 Standard SP1.

Thanks!

"David Lozzi" <dl****@nospam.nospamwrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
Hello there,

I'm getting the following error

System.NullReferenceException: Object reference not set to an instance of
an object.

at shopping_bag.GetBagTotals()

which then causes this following error which stops the application pool my
web application is running on

EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4
app_code, P5 1.0.2587.41853, P6 45c1694a, P7 a6, P8 0, P9
system.nullreferenceexception, P10 NIL.
The GetBagTotals does not have a null reference in it from what I can see.
I only get this error when a visitor hits a page that is non existent, for
example www.domain.com/otherpage.aspx. (recently updated the site so a lot
of pages are no longer there). When these pages are hit I get the
following:

Explanation: The Web server connection was closed.
Technical Information (for support personnel)

a.. Error Code 64: Host not available
b.. Background: The connection to the Web server was lost.
And the two errors listed above. I have the 404, 404;2,404;3 in IIS set to
go to an aspx page which works great if someone goes to an .html page that
is no longer available. Weird eh?

So if a user tries to visit a page that is no longer available and it ends
in aspx, they don't get a 404 error, they get what is displayed above and
then a null reference error occurs. If a user tries to visit a page that
ends in .html they get the correct 404 error page and no null errors.

Any ideas why aspx pages are not responding to a 404?

Thanks,

David Lozzi

Feb 1 '07 #2
oops, asp.net 2.0 application
"David Lozzi" <dl****@nospam.nospamwrote in message
news:uc**************@TK2MSFTNGP04.phx.gbl...
>I tried adding

<customErrors mode="RemoteOnly">

<error statusCode="400" redirect="notfound.aspx" />

<error statusCode="401" redirect="notfound.aspx" />

<error statusCode="403" redirect="notfound.aspx" />

<error statusCode="404" redirect="notfound.aspx" />

<error statusCode="408" redirect="notfound.aspx" />

<error statusCode="500" redirect="notfound.aspx" />

<error statusCode="503" redirect="notfound.aspx" />

</customErrors>

To the web.config file and that didn't work either. Still get the
previously stated errors.

I'm sorry, the server is a Win2003 Standard SP1.

Thanks!

"David Lozzi" <dl****@nospam.nospamwrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
>Hello there,

I'm getting the following error

System.NullReferenceException: Object reference not set to an instance of
an object.

at shopping_bag.GetBagTotals()

which then causes this following error which stops the application pool
my web application is running on

EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4
app_code, P5 1.0.2587.41853, P6 45c1694a, P7 a6, P8 0, P9
system.nullreferenceexception, P10 NIL.
The GetBagTotals does not have a null reference in it from what I can
see. I only get this error when a visitor hits a page that is non
existent, for example www.domain.com/otherpage.aspx. (recently updated
the site so a lot of pages are no longer there). When these pages are hit
I get the following:

Explanation: The Web server connection was closed.
Technical Information (for support personnel)

a.. Error Code 64: Host not available
b.. Background: The connection to the Web server was lost.
And the two errors listed above. I have the 404, 404;2,404;3 in IIS set
to go to an aspx page which works great if someone goes to an .html page
that is no longer available. Weird eh?

So if a user tries to visit a page that is no longer available and it
ends in aspx, they don't get a 404 error, they get what is displayed
above and then a null reference error occurs. If a user tries to visit a
page that ends in .html they get the correct 404 error page and no null
errors.

Any ideas why aspx pages are not responding to a 404?

Thanks,

David Lozzi


Feb 1 '07 #3
hi David,
it is clear that some of your application code is running when the
non-existent page is requested.
this is probably in application_beginrequest or session_start in
global.asax?
if not there must be some other httphandler or module running that is
invoking your code.
can you debug the server and set a breakpoint before the nullref exception?
then look at the stacktrace and see where it comes from. it will probably
say <non user codebut you may get a clue.

hope this helps
tim
"David Lozzi" <dl****@nospam.nospamwrote in message
news:eq**************@TK2MSFTNGP06.phx.gbl...
oops, asp.net 2.0 application
"David Lozzi" <dl****@nospam.nospamwrote in message
news:uc**************@TK2MSFTNGP04.phx.gbl...
>>I tried adding

<customErrors mode="RemoteOnly">

<error statusCode="400" redirect="notfound.aspx" />

<error statusCode="401" redirect="notfound.aspx" />

<error statusCode="403" redirect="notfound.aspx" />

<error statusCode="404" redirect="notfound.aspx" />

<error statusCode="408" redirect="notfound.aspx" />

<error statusCode="500" redirect="notfound.aspx" />

<error statusCode="503" redirect="notfound.aspx" />

</customErrors>

To the web.config file and that didn't work either. Still get the
previously stated errors.

I'm sorry, the server is a Win2003 Standard SP1.

Thanks!

"David Lozzi" <dl****@nospam.nospamwrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
>>Hello there,

I'm getting the following error

System.NullReferenceException: Object reference not set to an instance
of an object.

at shopping_bag.GetBagTotals()

which then causes this following error which stops the application pool
my web application is running on

EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4
app_code, P5 1.0.2587.41853, P6 45c1694a, P7 a6, P8 0, P9
system.nullreferenceexception, P10 NIL.
The GetBagTotals does not have a null reference in it from what I can
see. I only get this error when a visitor hits a page that is non
existent, for example www.domain.com/otherpage.aspx. (recently updated
the site so a lot of pages are no longer there). When these pages are
hit I get the following:

Explanation: The Web server connection was closed.
Technical Information (for support personnel)

a.. Error Code 64: Host not available
b.. Background: The connection to the Web server was lost.
And the two errors listed above. I have the 404, 404;2,404;3 in IIS set
to go to an aspx page which works great if someone goes to an .html page
that is no longer available. Weird eh?

So if a user tries to visit a page that is no longer available and it
ends in aspx, they don't get a 404 error, they get what is displayed
above and then a null reference error occurs. If a user tries to visit a
page that ends in .html they get the correct 404 error page and no null
errors.

Any ideas why aspx pages are not responding to a 404?

Thanks,

David Lozzi


Feb 1 '07 #4
also david, just to add to my previous reply.
i would bet a tenner that your shopping_bag object is null, and this is the
reason for the exception, rather than the exception occuring inside the
method itself.

tim

Feb 1 '07 #5
Try this :

Errors.aspx:
-----------------
<html>
<script language="VB" runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim errMessage As String = ""
Dim appException As System.Exception = Server.GetLastError()
If (TypeOf (appException) Is HttpException) Then
Dim checkException As HttpException = CType(appException, HttpException)
Select Case checkException.GetHttpCode
Case 400
errMessage &= "Bad request. The file size is too large."
Case 401
errMessage &= "You are not authorized to view this page."
Case 403
errMessage &= "You are not allowed to view that page."
Case 404
errMessage &= "The page you have requested can't be found."
Case 408
errMessage &= "The request has timed out."
Case 500
errMessage &= "The server can't fulfill your request."
Case Else
errMessage &= "The server has experienced an error."
End Select
Else
errMessage &= "The following error occurred<BR>" & appException.ToString
End If
ErrorMessage.Text = errMessage & "<BR>We're sorry for the inconvenience."
Server.ClearError()
End Sub
</script>

<body>
<hr>
<asp:label id="ErrorMessage" font-size="12" font-bold="true" runat=server/>
<hr>
<p>Return to <a href="http://www.server.com/"The site's entry page</a>
</body>
</html>
---------------

Modify the cases to taste.

Some will not be available because they're not customizable,
but 404s will be caught and the user will be redirected to the "errors.aspx" page.

You could also modify the response to perform other tasks.

Then, in your web.config, add either:

<customErrors mode="RemoteOnly" defaultRedirect="Errors.aspx"/>

or

<customErrors mode="On" defaultRedirect="Errors.aspx"/>


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"David Lozzi" <dl****@nospam.nospamwrote in message news:uc**************@TK2MSFTNGP04.phx.gbl...
>I tried adding

<customErrors mode="RemoteOnly">

<error statusCode="400" redirect="notfound.aspx" />

<error statusCode="401" redirect="notfound.aspx" />

<error statusCode="403" redirect="notfound.aspx" />

<error statusCode="404" redirect="notfound.aspx" />

<error statusCode="408" redirect="notfound.aspx" />

<error statusCode="500" redirect="notfound.aspx" />

<error statusCode="503" redirect="notfound.aspx" />

</customErrors>

To the web.config file and that didn't work either. Still get the previously stated errors.

I'm sorry, the server is a Win2003 Standard SP1.

Thanks!
Feb 1 '07 #6
Oops some more, sorry for the late info... ISA 2004 Standard is also running
on this server. The more I research this error I see more and more ISA
related issues however nothing pertaining to this yet.
"David Lozzi" <dl****@nospam.nospamwrote in message
news:uA**************@TK2MSFTNGP03.phx.gbl...
Hello there,

I'm getting the following error

System.NullReferenceException: Object reference not set to an instance of
an object.

at shopping_bag.GetBagTotals()

which then causes this following error which stops the application pool my
web application is running on

EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.1830, P3 42435be1, P4
app_code, P5 1.0.2587.41853, P6 45c1694a, P7 a6, P8 0, P9
system.nullreferenceexception, P10 NIL.
The GetBagTotals does not have a null reference in it from what I can see.
I only get this error when a visitor hits a page that is non existent, for
example www.domain.com/otherpage.aspx. (recently updated the site so a lot
of pages are no longer there). When these pages are hit I get the
following:

Explanation: The Web server connection was closed.
Technical Information (for support personnel)

a.. Error Code 64: Host not available
b.. Background: The connection to the Web server was lost.
And the two errors listed above. I have the 404, 404;2,404;3 in IIS set to
go to an aspx page which works great if someone goes to an .html page that
is no longer available. Weird eh?

So if a user tries to visit a page that is no longer available and it ends
in aspx, they don't get a 404 error, they get what is displayed above and
then a null reference error occurs. If a user tries to visit a page that
ends in .html they get the correct 404 error page and no null errors.

Any ideas why aspx pages are not responding to a 404?

Thanks,

David Lozzi

Feb 1 '07 #7

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

Similar topics

2
by: learner | last post by:
Hi, In a page, i have many links. I have some functions in a global file which is included in all linked pages. I want to have a reference to a window which is to be opened on clicking one link...
8
by: Tim::.. | last post by:
Can someone please tell me why I keep getting the following error for some of my web application users but not others??? Even though the application runs from a central webserver??? Thanks for...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
2
by: settyv | last post by:
Hi, I have webform which has 4 Datagrid controls with (built-in Pagination) and 4 search buttons to perform the search operation.When i click on search operation it is displaying the results in...
0
by: David Lozzi | last post by:
Hello there, I'm getting the following error System.NullReferenceException: Object reference not set to an instance of an object. at shopping_bag.GetBagTotals()
0
by: banderson777 | last post by:
Hello, I'm a bit new at in-depth IE programming, and am having a bit of trouble with a couple of IE browser extensions (getting them to talk to each other). The first one is a C++ Browser Helper...
3
by: tshad | last post by:
I have a file that I converted from VB.Net to C# that works fine in VB.Net when I compile but not in C# using the same libraries. The error I am getting is: PageInit.cs(9,7): error CS0138: A...
1
by: javabeginner123 | last post by:
i have a java prob, and i have to solve it fast, but i'm just getting to know it, so plz help me solve it with full code completed, thanks so much. the prob is to create a monter fight and there is...
2
by: itsvineeth209 | last post by:
My task is to create login control without using login control in tools. I shouldnt use sqldatasource or any other. I should use only data sets, data adapters and data readers etc. U had created...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.