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

global.aspx Application_error does not fire on anything other than

I've got a global.aspx file that works in my dev environment (vs 2005).
When i publish the site to a windows 2000 sp4 box running IIS, the global
does not seem to fire. Since it's a test server, i've tried granting the
user that IIS is using with all kinds of rights, that didn't work.... so is
there some setting i'm missing somewhere.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim olog As New dempsey.TextFile
With olog
.FileName = "500Errors.txt"

..SaveText("-------------------------------------------------------------")
Dim err As Exception = Server.GetLastError()

.SaveText(Err.ToString)
.SaveText(err.StackTrace)
End With

Response.Redirect("~/500Error.htm")
end sub

and an bit from the web.config file
<compilation debug="false" strict="false" explicit="true">

hope someone can help out...
just to be more complete.. in the appliction_error, i'm also writing some
info out to a sql database... again.. that works running things out of visual
studio.. but not when the code is published..

thanks
shannon
Jan 14 '08 #1
19 5096
try using

Server.GetLastError().GetBaseException()

That's where all the information is.
Then call Server.ClearError()
before you redirect.

Are you getting an exeption when the call to the Database is made? It's
another possibility that could be blowing everything up on you.

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"jvcoach23" wrote:
I've got a global.aspx file that works in my dev environment (vs 2005).
When i publish the site to a windows 2000 sp4 box running IIS, the global
does not seem to fire. Since it's a test server, i've tried granting the
user that IIS is using with all kinds of rights, that didn't work.... so is
there some setting i'm missing somewhere.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim olog As New dempsey.TextFile
With olog
.FileName = "500Errors.txt"

.SaveText("-------------------------------------------------------------")
Dim err As Exception = Server.GetLastError()

.SaveText(Err.ToString)
.SaveText(err.StackTrace)
End With

Response.Redirect("~/500Error.htm")
end sub

and an bit from the web.config file
<compilation debug="false" strict="false" explicit="true">

hope someone can help out...
just to be more complete.. in the appliction_error, i'm also writing some
info out to a sql database... again.. that works running things out of visual
studio.. but not when the code is published..

thanks
shannon
Jan 14 '08 #2
I'll try that..

I don't think the sql logging is causing any problems. I'm using a class to
write to the database, this class is using the same connection string that
all the other database calls are using and i'm able to do inserts for those.
i've watched in sql profiler and the sql box is not getting hit by the this
call... so i don't think it's firing... i understand though that if it was
getting chocked up on this, that it would make the call.. i've also tried
writing out to a log file, again, that works when running in visual studio,
but not when it is published.

"Peter Bromberg [C# MVP]" wrote:
try using

Server.GetLastError().GetBaseException()

That's where all the information is.
Then call Server.ClearError()
before you redirect.

Are you getting an exeption when the call to the Database is made? It's
another possibility that could be blowing everything up on you.

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"jvcoach23" wrote:
I've got a global.aspx file that works in my dev environment (vs 2005).
When i publish the site to a windows 2000 sp4 box running IIS, the global
does not seem to fire. Since it's a test server, i've tried granting the
user that IIS is using with all kinds of rights, that didn't work.... so is
there some setting i'm missing somewhere.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim olog As New dempsey.TextFile
With olog
.FileName = "500Errors.txt"

.SaveText("-------------------------------------------------------------")
Dim err As Exception = Server.GetLastError()

.SaveText(Err.ToString)
.SaveText(err.StackTrace)
End With

Response.Redirect("~/500Error.htm")
end sub

and an bit from the web.config file
<compilation debug="false" strict="false" explicit="true">

hope someone can help out...
just to be more complete.. in the appliction_error, i'm also writing some
info out to a sql database... again.. that works running things out of visual
studio.. but not when the code is published..

thanks
shannon
Jan 14 '08 #3
Hi Peter.. another question

what is a way that i can test.. or trap if there is something causing the
application_error to bomb.. i mean.. if i have something wrong with my code
or something else is going wrong, what is the best way to figure that out...

if the application_error is running, but i'm bombing out on some of my
code.. what is somethign that i can put in there to test to see if it's
running. i'll commit out all my code

hopefully that way i can give you better info so you can set me straight..

thanks
shannon

"Peter Bromberg [C# MVP]" <pb*******@yahoo.NoSpamMaam.comwrote in message
news:BC**********************************@microsof t.com...
try using

Server.GetLastError().GetBaseException()

That's where all the information is.
Then call Server.ClearError()
before you redirect.

Are you getting an exeption when the call to the Database is made? It's
another possibility that could be blowing everything up on you.

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"jvcoach23" wrote:
>I've got a global.aspx file that works in my dev environment (vs 2005).
When i publish the site to a windows 2000 sp4 box running IIS, the global
does not seem to fire. Since it's a test server, i've tried granting the
user that IIS is using with all kinds of rights, that didn't work.... so
is
there some setting i'm missing somewhere.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim olog As New dempsey.TextFile
With olog
.FileName = "500Errors.txt"

.SaveText("-------------------------------------------------------------")
Dim err As Exception = Server.GetLastError()

.SaveText(Err.ToString)
.SaveText(err.StackTrace)
End With

Response.Redirect("~/500Error.htm")
end sub

and an bit from the web.config file
<compilation debug="false" strict="false" explicit="true">

hope someone can help out...
just to be more complete.. in the appliction_error, i'm also writing some
info out to a sql database... again.. that works running things out of
visual
studio.. but not when the code is published..

thanks
shannon

Jan 14 '08 #4
Make sure the directory is marked at an IIS Application/virtual directory

Jeff
"jvcoach23" <jv*******@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
I've got a global.aspx file that works in my dev environment (vs 2005).
When i publish the site to a windows 2000 sp4 box running IIS, the global
does not seem to fire. Since it's a test server, i've tried granting the
user that IIS is using with all kinds of rights, that didn't work.... so
is
there some setting i'm missing somewhere.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim olog As New dempsey.TextFile
With olog
.FileName = "500Errors.txt"

.SaveText("-------------------------------------------------------------")
Dim err As Exception = Server.GetLastError()

.SaveText(Err.ToString)
.SaveText(err.StackTrace)
End With

Response.Redirect("~/500Error.htm")
end sub

and an bit from the web.config file
<compilation debug="false" strict="false" explicit="true">

hope someone can help out...
just to be more complete.. in the appliction_error, i'm also writing some
info out to a sql database... again.. that works running things out of
visual
studio.. but not when the code is published..

thanks
shannon

Jan 15 '08 #5
thanks for the comment.. it is..any other suggestions

"Jeff Dillon" <je********@hotmailremove.comwrote in message
news:e5**************@TK2MSFTNGP02.phx.gbl...
Make sure the directory is marked at an IIS Application/virtual directory

Jeff
"jvcoach23" <jv*******@discussions.microsoft.comwrote in message
news:23**********************************@microsof t.com...
>I've got a global.aspx file that works in my dev environment (vs 2005).
When i publish the site to a windows 2000 sp4 box running IIS, the global
does not seem to fire. Since it's a test server, i've tried granting the
user that IIS is using with all kinds of rights, that didn't work.... so
is
there some setting i'm missing somewhere.

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
Dim olog As New dempsey.TextFile
With olog
.FileName = "500Errors.txt"

.SaveText("-------------------------------------------------------------")
Dim err As Exception = Server.GetLastError()

.SaveText(Err.ToString)
.SaveText(err.StackTrace)
End With

Response.Redirect("~/500Error.htm")
end sub

and an bit from the web.config file
<compilation debug="false" strict="false" explicit="true">

hope someone can help out...
just to be more complete.. in the appliction_error, i'm also writing some
info out to a sql database... again.. that works running things out of
visual
studio.. but not when the code is published..

thanks
shannon


Jan 15 '08 #6
i did as you suggested... added the code to the application_error and
commented out all my code that was in that sub

added the new page

modified the web.config file

when i hit the page that does not exists, i get a page "The page cannot be
found" error. i do not get redirected.

so after having checked the rights for the user, uninstalling and
reinstalling .net and IIS, what is the next step in the troubleshooting
list.

thanks again for all the pointers and help. Hope you can continue to help
me through this.

thanks
shannon
Jan 16 '08 #7
Try using the .aspx extension...

Look at the difference between :

http://asp.net.do/test/some.html
and
http://asp.net.do/test/some.aspx

If you want non-existent .html pages to be responded to with a custom page,
add the extension to the files processed by ASP.NET.

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/
======================================
"jvcoach23" <sh******@sucss.state.il.uswrote in message news:di****************************@40tude.net...
>i did as you suggested... added the code to the application_error and
commented out all my code that was in that sub

added the new page

modified the web.config file

when i hit the page that does not exists, i get a page "The page cannot be
found" error. i do not get redirected.

so after having checked the rights for the user, uninstalling and
reinstalling .net and IIS, what is the next step in the troubleshooting
list.

thanks again for all the pointers and help. Hope you can continue to help
me through this.

thanks
shannon

Jan 16 '08 #8
Another option is to simply set a custom page for 404 errors in IIS.
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eJ**************@TK2MSFTNGP03.phx.gbl...
Try using the .aspx extension...

Look at the difference between :

http://asp.net.do/test/some.html
and
http://asp.net.do/test/some.aspx

If you want non-existent .html pages to be responded to with a custom
page,
add the extension to the files processed by ASP.NET.

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/
======================================
"jvcoach23" <sh******@sucss.state.il.uswrote in message
news:di****************************@40tude.net...
>>i did as you suggested... added the code to the application_error and
commented out all my code that was in that sub

added the new page

modified the web.config file

when i hit the page that does not exists, i get a page "The page cannot
be
found" error. i do not get redirected.

so after having checked the rights for the user, uninstalling and
reinstalling .net and IIS, what is the next step in the troubleshooting
list.

thanks again for all the pointers and help. Hope you can continue to
help
me through this.

thanks
shannon

Jan 16 '08 #9
"Scott Roberts" <sr******@no.spam.here-webworks-software.comwrote in
message news:O9**************@TK2MSFTNGP03.phx.gbl...
Another option is to simply set a custom page for 404 errors in IIS.
Not always an option with a public Internet site hosted with a 3rd-party
ISP...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Jan 16 '08 #10
re:
!Another option is to simply set a custom page for 404 errors in IIS.

404s for html, asp, etc. are handled "out of the box" by IIS,
without the need for a custom page for 404 errors, but .aspx files are not.

Remember, .aspx files go through the ASP.NET ISAPI application; html, asp, etc. files don't.

You're right, though, that is an option...for html files, for .asp files and,
in general, for any file that doesn't go through the ASP.NET ISAPI app.


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/
======================================
"Scott Roberts" <sr******@no.spam.here-webworks-software.comwrote in message
news:O9**************@TK2MSFTNGP03.phx.gbl...
Another option is to simply set a custom page for 404 errors in IIS.
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:eJ**************@TK2MSFTNGP03.phx.gbl...
>Try using the .aspx extension...

Look at the difference between :

http://asp.net.do/test/some.html
and
http://asp.net.do/test/some.aspx

If you want non-existent .html pages to be responded to with a custom page,
add the extension to the files processed by ASP.NET.

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/
======================================
"jvcoach23" <sh******@sucss.state.il.uswrote in message news:di****************************@40tude.net...
>>>i did as you suggested... added the code to the application_error and
commented out all my code that was in that sub

added the new page

modified the web.config file

when i hit the page that does not exists, i get a page "The page cannot be
found" error. i do not get redirected.

so after having checked the rights for the user, uninstalling and
reinstalling .net and IIS, what is the next step in the troubleshooting
list.

thanks again for all the pointers and help. Hope you can continue to help
me through this.

thanks
shannon


Jan 16 '08 #11
Here is the sub

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
Server.Transfer("~/Errors.aspx")
'some commented out code
End Sub

and the name of the file it's going to is Errors.aspx.. all the code in the
files is as you had.

I've double checked, republished and i'm getting teh page cannot be found
message.. The redirect never takes place.

your code does redirect when i run it from vb.

again.. thanks for the help.. hope your willing to continue
thanks
shannon
Jan 16 '08 #12
yep.. i understand what your saying. but in the global.asax file, i have
some code to gather some info and store it to a database... that's why i am
trying to go this route..

thanks for the input though
shannon

On Wed, 16 Jan 2008 11:45:56 -0600, Scott Roberts wrote:
Another option is to simply set a custom page for 404 errors in IIS.
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:eJ**************@TK2MSFTNGP03.phx.gbl...
Jan 16 '08 #13
ok.. the server.transfer seems to be working.. kind of.. need some
education here.

I loaded up sysinternals file monitor to see if i could better understand
if there was an access error. that is where i noticed that i was trying
to hit a file with an extension of aspx1... i put the 1 in my link to make
the file so that it was not found.. but after the post talking about the
html vs the aspx, i changed the dead link to be an aspx extension instead.

I republished and now i click on the dead link and the address bar shows
the dead link url, but the message on the screen is

The page you have requested can't be found.
We're sorry for the inconvenience.

from the page that i created per the advice of someone on this thread. so,
the server.transfer("~/Errors.aspx") verbage is showing up, but the url is
the dead link... does that sound correct.

i'm gonna put my code back in and keep on trying things.. just didn't want
someone running up the wrong tree trying to help guide me.. hoping somone
can still education me on the server.transfer and addresss line thing
mentioend above.

thanks
shannon
Jan 16 '08 #14
ahh.. the server.transfer is not happing at the client...if i were to do a
resposne.redirect, then that would actaully bring up the page url, cause
the client is the one issing the request... that more on track?

On Wed, 16 Jan 2008 13:50:11 -0600, jvcoach23 wrote:
ok.. the server.transfer seems to be working.. kind of.. need some
education here.

I loaded up sysinternals file monitor to see if i could better understand
if there was an access error. that is where i noticed that i was trying
to hit a file with an extension of aspx1... i put the 1 in my link to make
the file so that it was not found.. but after the post talking about the
html vs the aspx, i changed the dead link to be an aspx extension instead.

I republished and now i click on the dead link and the address bar shows
the dead link url, but the message on the screen is

The page you have requested can't be found.
We're sorry for the inconvenience.

from the page that i created per the advice of someone on this thread. so,
the server.transfer("~/Errors.aspx") verbage is showing up, but the url is
the dead link... does that sound correct.

i'm gonna put my code back in and keep on trying things.. just didn't want
someone running up the wrong tree trying to help guide me.. hoping somone
can still education me on the server.transfer and addresss line thing
mentioend above.

thanks
shannon
Jan 16 '08 #15
re:
!I republished and now i click on the dead link and the address bar shows
!the dead link url, but the message on the screen is

!The page you have requested can't be found.
!We're sorry for the inconvenience.

If that's the case, both global.asax and Application_Error are firing.

re:
!but the url is the dead link... does that sound correct.

Yes. Server.Transfer preserves the original link.
Errors.aspx will *not* show up on the address bar.

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/
======================================
"jvcoach23" <sh******@sucss.state.il.uswrote in message news:lz****************************@40tude.net...
ok.. the server.transfer seems to be working.. kind of.. need some
education here.

I loaded up sysinternals file monitor to see if i could better understand
if there was an access error. that is where i noticed that i was trying
to hit a file with an extension of aspx1... i put the 1 in my link to make
the file so that it was not found.. but after the post talking about the
html vs the aspx, i changed the dead link to be an aspx extension instead.

I republished and now i click on the dead link and the address bar shows
the dead link url, but the message on the screen is

The page you have requested can't be found.
We're sorry for the inconvenience.

from the page that i created per the advice of someone on this thread. so,
the server.transfer("~/Errors.aspx") verbage is showing up, but the url is
the dead link... does that sound correct.

i'm gonna put my code back in and keep on trying things.. just didn't want
someone running up the wrong tree trying to help guide me.. hoping somone
can still education me on the server.transfer and addresss line thing
mentioend above.

thanks
shannon

Jan 16 '08 #16
Yes, but you'd lose the capability to capture the error messages.
Response.redirect doesn't let you do that.


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/
======================================
"jvcoach23" <sh******@sucss.state.il.uswrote in message news:1l*****************************@40tude.net...
ahh.. the server.transfer is not happing at the client...if i were to do a
resposne.redirect, then that would actaully bring up the page url, cause
the client is the one issing the request... that more on track?

On Wed, 16 Jan 2008 13:50:11 -0600, jvcoach23 wrote:
>ok.. the server.transfer seems to be working.. kind of.. need some
education here.

I loaded up sysinternals file monitor to see if i could better understand
if there was an access error. that is where i noticed that i was trying
to hit a file with an extension of aspx1... i put the 1 in my link to make
the file so that it was not found.. but after the post talking about the
html vs the aspx, i changed the dead link to be an aspx extension instead.

I republished and now i click on the dead link and the address bar shows
the dead link url, but the message on the screen is

The page you have requested can't be found.
We're sorry for the inconvenience.

from the page that i created per the advice of someone on this thread. so,
the server.transfer("~/Errors.aspx") verbage is showing up, but the url is
the dead link... does that sound correct.

i'm gonna put my code back in and keep on trying things.. just didn't want
someone running up the wrong tree trying to help guide me.. hoping somone
can still education me on the server.transfer and addresss line thing
mentioend above.

thanks
shannon

Jan 16 '08 #17
so if you wnat to handle page not found links that are not aspx extensions,
like pdf files, then you need to use the customer error handling... cause
that won't go through the global... am i understanding that right.. is the
custom error the only option at that point... at least from a more web site
prospective..

thanks
shannon
>
404s for html, asp, etc. are handled "out of the box" by IIS,
without the need for a custom page for 404 errors, but .aspx files are not.
Jan 16 '08 #18
if i do the error message capturing before the server.transfer.. then i'd
be able to get the error message ok... that sound correct..

thanks
shannon
Jan 16 '08 #19
Yes. That's exactly what the sample I posted for you does.


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/
======================================
"jvcoach23" <sh******@sucss.state.il.uswrote in message news:16******************************@40tude.net.. .
if i do the error message capturing before the server.transfer.. then i'd
be able to get the error message ok... that sound correct..

thanks
shannon

Jan 16 '08 #20

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

Similar topics

3
by: Mike Malter | last post by:
I have a general error page that I configured in web.config as <customErrors mode="On" defaultRedirect="CRDefaultError.aspx" /> This error page comes up whenever an error occurs outside of any...
8
by: Thomas Coleman | last post by:
Ok, I've obviously discovered that Global.aspx has been completely changed in ..NET 2.0. However, I haven't figured out how to declare a constant that's available to any page in my application...
2
by: barry | last post by:
Hi I keep username and password in Global.aspx static public string un = ""; static public string pw = ""; after a user logs in i update un and pw with the input values. but if i start...
0
by: Greg | last post by:
I have an application that allows users to select one or more files to upload to the server. Each of the html file controls is stored in an array that is held in the session object. This allows...
1
by: vikram | last post by:
I want to provide a custom erro handler for my application. henc I decided to handle all error in Global.asax application_error event and then process the error respectively. Is there any problem...
6
by: Samuel Shulman | last post by:
I need to add some code to the Global.aspx file in the ASP.Net 2.0 project but I don't find and adding a module with such name doesn't give me the events that I need Thank you, Samuel
1
by: RedHair | last post by:
When global.aspx or web.config are changed , the web application will restart? Is it possible to change content of web.config in the applcation_start() of global.aspx? if yes, this will restart...
5
by: jobs | last post by:
re: try catch finally to close and dispose, but still want Application_error to fire 1. If catch an exception to to dispose and close of a ado connect, how can I allow the exception to still...
1
by: visweswaran2830 | last post by:
Hi, I want to redirect from global.aspx to another page. How can I achieve this. I tried with following steps, but no effects on this. 1) Response.Redirect("~/login.aspx") 2) ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
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.