By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,903 Members | 1,670 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,903 IT Pros & Developers. It's quick & easy.

URGENT Getting null reference errors on 404??

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.