Global.aspx, maybe I don't understand?

L

Larry Bud

Hi all. I have a webservice that calls a class, does some processing,
and returns some XML.

I would like to have a global exception handler to catch any misc
exceptions. From what I understand, I can create a global.aspx file
in my web service folder, add an Application_Error sub, and any system
exceptions will fire that off.

Right now I'm just setting the value of a local var so I can set a
breakpoint. An exception occurs in my app (a file not found
exception), but I get the raw exception message to the screen.
Application_error is never fired.

Is something wrote or am I totally misunderstanding the use of
Application_Error? I don't want to have catch/try through the
application...
 
M

Michael Nemtsev [MVP]

Hello Larry,

Could you set breakpoints on Application_Start to verify that your global.aspx
works?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


LB> Hi all. I have a webservice that calls a class, does some
LB> processing, and returns some XML.
LB>
LB> I would like to have a global exception handler to catch any misc
LB> exceptions. From what I understand, I can create a global.aspx file
LB> in my web service folder, add an Application_Error sub, and any
LB> system exceptions will fire that off.
LB>
LB> Right now I'm just setting the value of a local var so I can set a
LB> breakpoint. An exception occurs in my app (a file not found
LB> exception), but I get the raw exception message to the screen.
LB> Application_error is never fired.
LB>
LB> Is something wrote or am I totally misunderstanding the use of
LB> Application_Error? I don't want to have catch/try through the
LB> application...
LB>
 
M

Michael Nemtsev [MVP]

Hello Scott,

Yep, I just mistyped.
That's why I asked about Application_Start breakpoint.
It seems that global.asax dont get any requests, because it's probably ASPX
not ASAX

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


SR> Shouldn't the name be Global.asax and not Global.aspx?
SR>
SR> SR>
Hello Larry,

Could you set breakpoints on Application_Start to verify that your
global.aspx works?

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high
and we
miss it, but that it is too low and we reach it" (c) Michelangelo
LB> Hi all. I have a webservice that calls a class, does some
LB> processing, and returns some XML.
LB> LB> I would like to have a global exception handler to catch any
misc
LB> exceptions. From what I understand, I can create a global.aspx
file
LB> in my web service folder, add an Application_Error sub, and any
LB> system exceptions will fire that off.
LB> LB> Right now I'm just setting the value of a local var so I can
set a
LB> breakpoint. An exception occurs in my app (a file not found
LB> exception), but I get the raw exception message to the screen.
LB> Application_error is never fired.
LB> LB> Is something wrote or am I totally misunderstanding the use
of
LB> Application_Error? I don't want to have catch/try through the
LB> application...
LB>
 
L

Larry Bud

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

LB> Hi all.  I have a webservice that calls a class, does some
LB> processing, and returns some XML.
LB>
LB> I would like to have a global exception handler to catch any misc
LB> exceptions.  From what I understand, I can create a global.aspx file
LB> in my web service folder, add an Application_Error sub, and any
LB> system exceptions will fire that off.
LB>
LB> Right now I'm just setting the value of a local var so I can set a
LB> breakpoint.  An exception occurs in my app (a file not found
LB> exception), but I get the raw exception message to the screen.
LB> Application_error is never fired.
LB>
LB> Is something wrote or am I totally misunderstanding the use of
LB> Application_Error?  I don't want to have catch/try through the
LB> application...
LB>

Hello Larry,

Could you set breakpoints on Application_Start to verify that your global.aspx
works?

Yep, Application_Start is firing. BTW, it IS named global.asax, just
a typo in the subject line.
 
L

Larry Bud

Application_Error needs to have code like:
Exception ex = Server.GetLastError().GetBaseException();
// do whatever you want with ex here


It's never even executing Application_Error
 
L

Larry Bud

Yep, Application_Start is firing.  BTW, it IS named global.asax, just
a typo in the subject line.- Hide quoted text -

Also, would the fact that this be a web service matter at all?
 
L

Larry Bud

Yep, Application_Start is firing.  BTW, it IS named global.asax, just
a typo in the subject line.- Hide quoted text -

OK, another update. I changed the reference to the codebehind in the
ASMX for testing purposes, and it kicked off Application_Error.

But, it didn't get kicked off when a System.IO.Exception was kicked
off in some of the codebehind (a file not found when trying to open
error).

All errors are to be caught with Application_Error, right?
 
L

Larry Bud

---
WBR,
Michael  Nemtsev [.NET/C# MVP] :: blog:http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
LB> Hi all.  I have a webservice that calls a class, does some
LB> processing, and returns some XML.
LB>
LB> I would like to have aglobalexceptionhandler to catch any misc
LB> exceptions.  From what I understand, I can create aglobal.aspx file
LB> in my web service folder, add an Application_Error sub, and any
LB> system exceptions will fire that off.
LB>
LB> Right now I'm just setting the value of a local var so I can set a
LB> breakpoint.  Anexceptionoccurs in my app (a file not found
LB>exception), but I get the rawexceptionmessage to the screen.
LB> Application_error is never fired.
LB>
LB> Is something wrote or am I totally misunderstanding the use of
LB> Application_Error?  I don't want to have catch/try through the
LB> application...
LB>
Yep, Application_Start is firing.  BTW, it IS namedglobal.asax, just
a typo in the subject line.- Hide quoted text -

OK, another update.  I changed the reference to the codebehind in the
ASMX for testing purposes, and it kicked off Application_Error.

But, it didn't get kicked off when a System.IO.Exception was kicked
off in some of the codebehind (a file not found when trying to open
error).

All errors are to be caught with Application_Error, right?- Hide quoted text -

Any other help?
 
L

Larry Bud

Hello Scott,

Yep, I just mistyped.
That's why I asked about Application_Start breakpoint.
It seems that global.asax dont get any requests, because it's probably ASPX
not ASAX

Michael, any other ides? The file is asax...
 
G

George Ter-Saakov

2 things..

1. Folder is not configured as an Application in IIS Management console.
2. Possible exception happens that prevents successful completion of
execution of the Application_Start hence it looks like it was not called.
The problem is that there is no visual confirmation that Application_Start
threw an error. Check NT event log. There will be a record there.


George.


Hello Scott,

Yep, I just mistyped.
That's why I asked about Application_Start breakpoint.
It seems that global.asax dont get any requests, because it's probably
ASPX
not ASAX

Michael, any other ides? The file is asax...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top