Board index » Web Programming » Application_Start exceptions

Application_Start exceptions

Web Programming367
I am attempting to handle errors by using Application_Error. This seems to

work fine in most situations. However, if the exception occurs during the

Application_Start method, the stand error screen is displayed and my custom

error handling in Application_Error does not run.



Why does this occur, and is there something I can do to cause

Application_Error to be automatically invoked during an Application_Start

exception?


-
 

Re:Application_Start exceptions

Hi Leslie:



Have you tried stepping through Application_Start with the debugger?



With Visual studio, set a breakpoint [1] in Application Start and hit

F5 to launch the debugger. There is also a whitepaper with some links

on using the debugger [2].



You might also investigate Try / Catch blocks to handle the exception

and log it. You won't be able to get into Application_Error from

Application_Start because the request processing hasn't started as

yet, but you could still log the error.



[1]

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/vsdebug/html/_asug_setting_breakpoints.asp



[2]

msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debugging.aspx">msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debugging.aspx





--

Scott

www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/



On Mon, 11 Jul 2005 15:43:03 -0700, Leslie <mason@newsgroup.nospam>

wrote:



Quote
I am attempting to handle errors by using Application_Error. This seems to

work fine in most situations. However, if the exception occurs during the

Application_Start method, the stand error screen is displayed and my custom

error handling in Application_Error does not run.



Why does this occur, and is there something I can do to cause

Application_Error to be automatically invoked during an Application_Start

exception?



-

Re:Application_Start exceptions

Thanks for Scott's inputs.



Hi Leslie,



As for the problem that exceptions in the Applicaion_Start event can't be

captured in Application_Error global event, it's limited by the ASP.NET's

error handling and request processing model:



The ASP.NET runtime will startup the application's instance(Application

instance) if found the applicaiton being requested the first time, and then

the Applicaiton_Start event will be fired. This event's event handler code

is executed before any other request processing code(event the httpmodule

code). And for Applicaiton_Error (the asp.net application global exception

event ) , it is implemented by put a large



try....catch.... block around the request Handler's ProcessRequest method,

and then unhandled exception occurs, the runtime call the global exception

handler( application_error) if exists in the catch block.



So we can see that any unhandled exception thrown in Application_Start is

out of the control of the Application_Error handler, if we need to capture

them, we have to explicitly put exception handling block in the

Applicaiton_Error handler.



Thanks,



Steven Cheng

Microsoft Online Support



Get Secure! www.microsoft.com/security

(This posting is provided "AS IS", with no warranties, and confers no

rights.)









--------------------

| From: Scott Allen <scott@nospam.odetocode.com>

| Subject: Re: Application_Start exceptions

| Date: Mon, 11 Jul 2005 20:31:29 -0400

| Message-ID: <cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

| X-Newsreader: Forte Agent 1.8/32.548

| MIME-Version: 1.0

| Content-Type: text/plain; charset=us-ascii

| Content-Transfer-Encoding: 7bit

| Newsgroups: microsoft.public.dotnet.framework.aspnet

| NNTP-Posting-Host: dyn-13-227.myactv.net 24.89.13.227

| Lines: 1

| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl

| Xref: TK2MSFTNGXA01.phx.gbl

microsoft.public.dotnet.framework.aspnet:111583

| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|

| Hi Leslie:

|

| Have you tried stepping through Application_Start with the debugger?

|

| With Visual studio, set a breakpoint [1] in Application Start and hit

| F5 to launch the debugger. There is also a whitepaper with some links

| on using the debugger [2].

|

| You might also investigate Try / Catch blocks to handle the exception

| and log it. You won't be able to get into Application_Error from

| Application_Start because the request processing hasn't started as

| yet, but you could still log the error.

|

| [1]

|

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/vsdebug/htm

l/_asug_setting_breakpoints.asp

|

| [2]

|

msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi">msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi

ng.aspx

|

|

| --

| Scott

| www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/

|

| On Mon, 11 Jul 2005 15:43:03 -0700, Leslie <mason@newsgroup.nospam>

| wrote:

|

|>I am attempting to handle errors by using Application_Error. This seems

to

|>work fine in most situations. However, if the exception occurs during

the

|>Application_Start method, the stand error screen is displayed and my

custom

|>error handling in Application_Error does not run.

|>

|>Why does this occur, and is there something I can do to cause

|>Application_Error to be automatically invoked during an

Application_Start

|>exception?

|

|



-

Re:Application_Start exceptions

Thanks Scott and Steve,



This let's me know that I am not doing something wrong. I will put a

try/catch block in my Application_Start routine to catch the exceptions.



One other thing, Do you know of any Microsoft documentation that details out

the ASP.NET runtime processing you refer to below?



Thanks,



Leslie



"Steven Cheng[MSFT]" wrote:



Quote
Thanks for Scott's inputs.



Hi Leslie,



As for the problem that exceptions in the Applicaion_Start event can't be

captured in Application_Error global event, it's limited by the ASP.NET's

error handling and request processing model:



The ASP.NET runtime will startup the application's instance(Application

instance) if found the applicaiton being requested the first time, and then

the Applicaiton_Start event will be fired. This event's event handler code

is executed before any other request processing code(event the httpmodule

code). And for Applicaiton_Error (the asp.net application global exception

event ) , it is implemented by put a large



try....catch.... block around the request Handler's ProcessRequest method,

and then unhandled exception occurs, the runtime call the global exception

handler( application_error) if exists in the catch block.



So we can see that any unhandled exception thrown in Application_Start is

out of the control of the Application_Error handler, if we need to capture

them, we have to explicitly put exception handling block in the

Applicaiton_Error handler.



Thanks,



Steven Cheng

Microsoft Online Support



Get Secure! www.microsoft.com/security

(This posting is provided "AS IS", with no warranties, and confers no

rights.)









--------------------

| From: Scott Allen <scott@nospam.odetocode.com>

| Subject: Re: Application_Start exceptions

| Date: Mon, 11 Jul 2005 20:31:29 -0400

| Message-ID: <cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

| X-Newsreader: Forte Agent 1.8/32.548

| MIME-Version: 1.0

| Content-Type: text/plain; charset=us-ascii

| Content-Transfer-Encoding: 7bit

| Newsgroups: microsoft.public.dotnet.framework.aspnet

| NNTP-Posting-Host: dyn-13-227.myactv.net 24.89.13.227

| Lines: 1

| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl

| Xref: TK2MSFTNGXA01.phx.gbl

microsoft.public.dotnet.framework.aspnet:111583

| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|

| Hi Leslie:

|

| Have you tried stepping through Application_Start with the debugger?

|

| With Visual studio, set a breakpoint [1] in Application Start and hit

| F5 to launch the debugger. There is also a whitepaper with some links

| on using the debugger [2].

|

| You might also investigate Try / Catch blocks to handle the exception

| and log it. You won't be able to get into Application_Error from

| Application_Start because the request processing hasn't started as

| yet, but you could still log the error.

|

| [1]

|

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/vsdebug/htm

l/_asug_setting_breakpoints.asp

|

| [2]

|

msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi">msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi

ng.aspx

|

|

| --

| Scott

| www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/

|

| On Mon, 11 Jul 2005 15:43:03 -0700, Leslie <mason@newsgroup.nospam>

| wrote:

|

|>I am attempting to handle errors by using Application_Error. This seems

to

|>work fine in most situations. However, if the exception occurs during

the

|>Application_Start method, the stand error screen is displayed and my

custom

|>error handling in Application_Error does not run.

|>

|>Why does this occur, and is there something I can do to cause

|>Application_Error to be automatically invoked during an

Application_Start

|>exception?

|

|





-

Re:Application_Start exceptions

Hi Leslie,



For the detailed description on the internal exception handling

implementation, there hasn't any document focus on this. I've ever seen

some MSDN tech articles (about the related topic ) mentioned this. Also

here are some msdn reference which are helpful for understanding the

ASP.NET's runtime request processing and the pipeline:



#The ASP.NET HTTP Runtime

msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim">msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim

e.asp?frame=true



#Securely Implement Request Processing, Filtering, and Content Redirection

with HTTP Pipelines in ASP.NET

msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx">msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx



In addition, I also recommend that you try using the .NET Reflector tool to

have a look at the reassemblied code of the HttpRuntime or Page class (the

ProcessRequest method) which will also greatly help us understanding the

internal mechanism.



Hope also helps. Thanks,



Steven Cheng

Microsoft Online Support



Get Secure! www.microsoft.com/security

(This posting is provided "AS IS", with no warranties, and confers no

rights.)













--------------------

| Thread-Topic: Application_Start exceptions

| thread-index: AcWHwSJCXiyAY+QyQrGgdmgu0r4nzw==

| X-WBNR-Posting-Host: 128.158.92.43

| From: =?Utf-8?B?TGVzbGll?= <mason@newsgroup.nospam>

| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

<cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

<dLnfHSrhFHA.1336@TK2MSFTNGXA01.phx.gbl>

| Subject: Re: Application_Start exceptions

| Date: Wed, 13 Jul 2005 08:40:02 -0700

| Lines: 115

| Message-ID: <03D44B5F-8962-4104-AA2E-4A37382DA34B@microsoft.com>

| MIME-Version: 1.0

| Content-Type: text/plain;

| charset="Utf-8"

| Content-Transfer-Encoding: 7bit

| X-Newsreader: Microsoft CDO for Windows 2000

| Content-Class: urn:content-classes:message

| Importance: normal

| Priority: normal

| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0

| Newsgroups: microsoft.public.dotnet.framework.aspnet

| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250

| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl

| Xref: TK2MSFTNGXA01.phx.gbl

microsoft.public.dotnet.framework.aspnet:111963

| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|

| Thanks Scott and Steve,

|

| This let's me know that I am not doing something wrong. I will put a

| try/catch block in my Application_Start routine to catch the exceptions.

|

| One other thing, Do you know of any Microsoft documentation that details

out

| the ASP.NET runtime processing you refer to below?

|

| Thanks,

|

| Leslie

|

| "Steven Cheng[MSFT]" wrote:

|

|>Thanks for Scott's inputs.

|>

|>Hi Leslie,

|>

|>As for the problem that exceptions in the Applicaion_Start event can't

be

|>captured in Application_Error global event, it's limited by the

ASP.NET's

|>error handling and request processing model:

|>

|>The ASP.NET runtime will startup the application's instance(Application

|>instance) if found the applicaiton being requested the first time, and

then

|>the Applicaiton_Start event will be fired. This event's event handler

code

|>is executed before any other request processing code(event the

httpmodule

|>code). And for Applicaiton_Error (the asp.net application global

exception

|>event ) , it is implemented by put a large

|>

|>try....catch.... block around the request Handler's ProcessRequest

method,

|>and then unhandled exception occurs, the runtime call the global

exception

|>handler( application_error) if exists in the catch block.

|>

|>So we can see that any unhandled exception thrown in Application_Start

is

|>out of the control of the Application_Error handler, if we need to

capture

|>them, we have to explicitly put exception handling block in the

|>Applicaiton_Error handler.

|>

|>Thanks,

|>

|>Steven Cheng

|>Microsoft Online Support

|>

|>Get Secure! www.microsoft.com/security

|>(This posting is provided "AS IS", with no warranties, and confers no

|>rights.)

|>

|>

|>

|>

|>--------------------

|>| From: Scott Allen <scott@nospam.odetocode.com>

|>| Subject: Re: Application_Start exceptions

|>| Date: Mon, 11 Jul 2005 20:31:29 -0400

|>| Message-ID: <cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

|>| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

|>| X-Newsreader: Forte Agent 1.8/32.548

|>| MIME-Version: 1.0

|>| Content-Type: text/plain; charset=us-ascii

|>| Content-Transfer-Encoding: 7bit

|>| Newsgroups: microsoft.public.dotnet.framework.aspnet

|>| NNTP-Posting-Host: dyn-13-227.myactv.net 24.89.13.227

|>| Lines: 1

|>| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl

|>| Xref: TK2MSFTNGXA01.phx.gbl

|>microsoft.public.dotnet.framework.aspnet:111583

|>| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|>|

|>| Hi Leslie:

|>|

|>| Have you tried stepping through Application_Start with the debugger?

|>|

|>| With Visual studio, set a breakpoint [1] in Application Start and hit

|>| F5 to launch the debugger. There is also a whitepaper with some links

|>| on using the debugger [2].

|>|

|>| You might also investigate Try / Catch blocks to handle the exception

|>| and log it. You won't be able to get into Application_Error from

|>| Application_Start because the request processing hasn't started as

|>| yet, but you could still log the error.

|>|

|>| [1]

|>|

|>

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/vsdebug/htm

|>l/_asug_setting_breakpoints.asp

|>|

|>| [2]

|>|

|>

msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi">msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi

|>ng.aspx

|>|

|>|

|>| --

|>| Scott

|>| www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/

|>|

|>| On Mon, 11 Jul 2005 15:43:03 -0700, Leslie <mason@newsgroup.nospam>

|>| wrote:

|>|

|>|>I am attempting to handle errors by using Application_Error. This

seems

|>to

|>|>work fine in most situations. However, if the exception occurs

during

|>the

|>|>Application_Start method, the stand error screen is displayed and my

|>custom

|>|>error handling in Application_Error does not run.

|>|>

|>|>Why does this occur, and is there something I can do to cause

|>|>Application_Error to be automatically invoked during an

|>Application_Start

|>|>exception?

|>|

|>|

|>

|>

|



-

Re:Application_Start exceptions

Thanks Steven,



That is what I was looking for.



Leslie

"Steven Cheng[MSFT]" <stcheng@online.microsoft.com>wrote in message

Quote
Hi Leslie,



For the detailed description on the internal exception handling

implementation, there hasn't any document focus on this. I've ever seen

some MSDN tech articles (about the related topic ) mentioned this. Also

here are some msdn reference which are helpful for understanding the

ASP.NET's runtime request processing and the pipeline:



#The ASP.NET HTTP Runtime

msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim">msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim

e.asp?frame=true



#Securely Implement Request Processing, Filtering, and Content Redirection

with HTTP Pipelines in ASP.NET

msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx">msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx



In addition, I also recommend that you try using the .NET Reflector tool

to

have a look at the reassemblied code of the HttpRuntime or Page class (the

ProcessRequest method) which will also greatly help us understanding the

internal mechanism.



Hope also helps. Thanks,



Steven Cheng

Microsoft Online Support



Get Secure! www.microsoft.com/security

(This posting is provided "AS IS", with no warranties, and confers no

rights.)













--------------------

| Thread-Topic: Application_Start exceptions

| thread-index: AcWHwSJCXiyAY+QyQrGgdmgu0r4nzw==

| X-WBNR-Posting-Host: 128.158.92.43

| From: =?Utf-8?B?TGVzbGll?= <mason@newsgroup.nospam>

| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

<cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

<dLnfHSrhFHA.1336@TK2MSFTNGXA01.phx.gbl>

| Subject: Re: Application_Start exceptions

| Date: Wed, 13 Jul 2005 08:40:02 -0700

| Lines: 115

| Message-ID: <03D44B5F-8962-4104-AA2E-4A37382DA34B@microsoft.com>

| MIME-Version: 1.0

| Content-Type: text/plain;

| charset="Utf-8"

| Content-Transfer-Encoding: 7bit

| X-Newsreader: Microsoft CDO for Windows 2000

| Content-Class: urn:content-classes:message

| Importance: normal

| Priority: normal

| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0

| Newsgroups: microsoft.public.dotnet.framework.aspnet

| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250

| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl

| Xref: TK2MSFTNGXA01.phx.gbl

microsoft.public.dotnet.framework.aspnet:111963

| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|

| Thanks Scott and Steve,

|

| This let's me know that I am not doing something wrong. I will put a

| try/catch block in my Application_Start routine to catch the exceptions.

|

| One other thing, Do you know of any Microsoft documentation that details

out

| the ASP.NET runtime processing you refer to below?

|

| Thanks,

|

| Leslie

|

| "Steven Cheng[MSFT]" wrote:

|

|>Thanks for Scott's inputs.

|>

|>Hi Leslie,

|>

|>As for the problem that exceptions in the Applicaion_Start event can't

be

|>captured in Application_Error global event, it's limited by the

ASP.NET's

|>error handling and request processing model:

|>

|>The ASP.NET runtime will startup the application's

instance(Application

|>instance) if found the applicaiton being requested the first time, and

then

|>the Applicaiton_Start event will be fired. This event's event handler

code

|>is executed before any other request processing code(event the

httpmodule

|>code). And for Applicaiton_Error (the asp.net application global

exception

|>event ) , it is implemented by put a large

|>

|>try....catch.... block around the request Handler's ProcessRequest

method,

|>and then unhandled exception occurs, the runtime call the global

exception

|>handler( application_error) if exists in the catch block.

|>

|>So we can see that any unhandled exception thrown in Application_Start

is

|>out of the control of the Application_Error handler, if we need to

capture

|>them, we have to explicitly put exception handling block in the

|>Applicaiton_Error handler.

|>

|>Thanks,

|>

|>Steven Cheng

|>Microsoft Online Support

|>

|>Get Secure! www.microsoft.com/security

|>(This posting is provided "AS IS", with no warranties, and confers no

|>rights.)

|>

|>

|>

|>

|>--------------------

|>| From: Scott Allen <scott@nospam.odetocode.com>

|>| Subject: Re: Application_Start exceptions

|>| Date: Mon, 11 Jul 2005 20:31:29 -0400

|>| Message-ID: <cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

|>| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

|>| X-Newsreader: Forte Agent 1.8/32.548

|>| MIME-Version: 1.0

|>| Content-Type: text/plain; charset=us-ascii

|>| Content-Transfer-Encoding: 7bit

|>| Newsgroups: microsoft.public.dotnet.framework.aspnet

|>| NNTP-Posting-Host: dyn-13-227.myactv.net 24.89.13.227

|>| Lines: 1

|>| Path:

TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl

|>| Xref: TK2MSFTNGXA01.phx.gbl

|>microsoft.public.dotnet.framework.aspnet:111583

|>| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|>|

|>| Hi Leslie:

|>|

|>| Have you tried stepping through Application_Start with the debugger?

|>|

|>| With Visual studio, set a breakpoint [1] in Application Start and

hit

|>| F5 to launch the debugger. There is also a whitepaper with some

links

|>| on using the debugger [2].

|>|

|>| You might also investigate Try / Catch blocks to handle the

exception

|>| and log it. You won't be able to get into Application_Error from

|>| Application_Start because the request processing hasn't started as

|>| yet, but you could still log the error.

|>|

|>| [1]

|>|

|>

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/vsdebug/htm

|>l/_asug_setting_breakpoints.asp

|>|

|>| [2]

|>|

|>

msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi">msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi

|>ng.aspx

|>|

|>|

|>| --

|>| Scott

|>| www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/

|>|

|>| On Mon, 11 Jul 2005 15:43:03 -0700, Leslie <mason@newsgroup.nospam>

|>| wrote:

|>|

|>|>I am attempting to handle errors by using Application_Error. This

seems

|>to

|>|>work fine in most situations. However, if the exception occurs

during

|>the

|>|>Application_Start method, the stand error screen is displayed and

my

|>custom

|>|>error handling in Application_Error does not run.

|>|>

|>|>Why does this occur, and is there something I can do to cause

|>|>Application_Error to be automatically invoked during an

|>Application_Start

|>|>exception?

|>|

|>|

|>

|>

|







-

Re:Application_Start exceptions

You're welcome :)



Steven Cheng

Microsoft Online Support



Get Secure! www.microsoft.com/security

(This posting is provided "AS IS", with no warranties, and confers no

rights.)

--------------------

| From: "Leslie Mason" <mason@newsgroup.nospam>

| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

<cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

<dLnfHSrhFHA.1336@TK2MSFTNGXA01.phx.gbl>

<03D44B5F-8962-4104-AA2E-4A37382DA34B@microsoft.com>

<Dz8$6UDiFHA.3296@TK2MSFTNGXA01.phx.gbl>

| Subject: Re: Application_Start exceptions

| Date: Thu, 14 Jul 2005 08:59:07 -0500

| Lines: 211

| X-Priority: 3

| X-MSMail-Priority: Normal

| X-Newsreader: Microsoft Outlook Express 6.00.2900.2180

| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180

| X-RFC2646: Format=Flowed; Original

| Message-ID: <u9YY4wHiFHA.1416@TK2MSFTNGP09.phx.gbl>

| Newsgroups: microsoft.public.dotnet.framework.aspnet

| NNTP-Posting-Host: ip24-253-198-205.ok.ok.cox.net 24.253.198.205

| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09.phx.gbl

| Xref: TK2MSFTNGXA01.phx.gbl

microsoft.public.dotnet.framework.aspnet:112179

| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|

| Thanks Steven,

|

| That is what I was looking for.

|

| Leslie

| "Steven Cheng[MSFT]" <stcheng@online.microsoft.com>wrote in message

| news:Dz8$6UDiFHA.3296@TK2MSFTNGXA01.phx.gbl...

|>Hi Leslie,

|>

|>For the detailed description on the internal exception handling

|>implementation, there hasn't any document focus on this. I've ever seen

|>some MSDN tech articles (about the related topic ) mentioned this. Also

|>here are some msdn reference which are helpful for understanding the

|>ASP.NET's runtime request processing and the pipeline:

|>

|>#The ASP.NET HTTP Runtime

|>

msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim">msdn.microsoft.com/library/en-us/dnaspp/html/dngrfTheASPNETHTTPRuntim

|>e.asp?frame=true

|>

|>#Securely Implement Request Processing, Filtering, and Content

Redirection

|>with HTTP Pipelines in ASP.NET

|>

msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx">msdn.microsoft.com/msdnmag/issues/02/09/HTTPPipelines/default.aspx

|>

|>In addition, I also recommend that you try using the .NET Reflector

tool

|>to

|>have a look at the reassemblied code of the HttpRuntime or Page class

(the

|>ProcessRequest method) which will also greatly help us understanding the

|>internal mechanism.

|>

|>Hope also helps. Thanks,

|>

|>Steven Cheng

|>Microsoft Online Support

|>

|>Get Secure! www.microsoft.com/security

|>(This posting is provided "AS IS", with no warranties, and confers no

|>rights.)

|>

|>

|>

|>

|>

|>

|>--------------------

|>| Thread-Topic: Application_Start exceptions

|>| thread-index: AcWHwSJCXiyAY+QyQrGgdmgu0r4nzw==

|>| X-WBNR-Posting-Host: 128.158.92.43

|>| From: =?Utf-8?B?TGVzbGll?= <mason@newsgroup.nospam>

|>| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

|><cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

|><dLnfHSrhFHA.1336@TK2MSFTNGXA01.phx.gbl>

|>| Subject: Re: Application_Start exceptions

|>| Date: Wed, 13 Jul 2005 08:40:02 -0700

|>| Lines: 115

|>| Message-ID: <03D44B5F-8962-4104-AA2E-4A37382DA34B@microsoft.com>

|>| MIME-Version: 1.0

|>| Content-Type: text/plain;

|>| charset="Utf-8"

|>| Content-Transfer-Encoding: 7bit

|>| X-Newsreader: Microsoft CDO for Windows 2000

|>| Content-Class: urn:content-classes:message

|>| Importance: normal

|>| Priority: normal

|>| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0

|>| Newsgroups: microsoft.public.dotnet.framework.aspnet

|>| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250

|>| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl

|>| Xref: TK2MSFTNGXA01.phx.gbl

|>microsoft.public.dotnet.framework.aspnet:111963

|>| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|>|

|>| Thanks Scott and Steve,

|>|

|>| This let's me know that I am not doing something wrong. I will put a

|>| try/catch block in my Application_Start routine to catch the

exceptions.

|>|

|>| One other thing, Do you know of any Microsoft documentation that

details

|>out

|>| the ASP.NET runtime processing you refer to below?

|>|

|>| Thanks,

|>|

|>| Leslie

|>|

|>| "Steven Cheng[MSFT]" wrote:

|>|

|>|>Thanks for Scott's inputs.

|>|>

|>|>Hi Leslie,

|>|>

|>|>As for the problem that exceptions in the Applicaion_Start event

can't

|>be

|>|>captured in Application_Error global event, it's limited by the

|>ASP.NET's

|>|>error handling and request processing model:

|>|>

|>|>The ASP.NET runtime will startup the application's

|>instance(Application

|>|>instance) if found the applicaiton being requested the first time,

and

|>then

|>|>the Applicaiton_Start event will be fired. This event's event

handler

|>code

|>|>is executed before any other request processing code(event the

|>httpmodule

|>|>code). And for Applicaiton_Error (the asp.net application global

|>exception

|>|>event ) , it is implemented by put a large

|>|>

|>|>try....catch.... block around the request Handler's ProcessRequest

|>method,

|>|>and then unhandled exception occurs, the runtime call the global

|>exception

|>|>handler( application_error) if exists in the catch block.

|>|>

|>|>So we can see that any unhandled exception thrown in

Application_Start

|>is

|>|>out of the control of the Application_Error handler, if we need to

|>capture

|>|>them, we have to explicitly put exception handling block in the

|>|>Applicaiton_Error handler.

|>|>

|>|>Thanks,

|>|>

|>|>Steven Cheng

|>|>Microsoft Online Support

|>|>

|>|>Get Secure! www.microsoft.com/security

|>|>(This posting is provided "AS IS", with no warranties, and confers

no

|>|>rights.)

|>|>

|>|>

|>|>

|>|>

|>|>--------------------

|>|>| From: Scott Allen <scott@nospam.odetocode.com>

|>|>| Subject: Re: Application_Start exceptions

|>|>| Date: Mon, 11 Jul 2005 20:31:29 -0400

|>|>| Message-ID: <cd36d1dj6oja4cpkg9ivv0a6mv4lrapak9@4ax.com>

|>|>| References: <C73572F6-BB5A-46A1-9E30-7781F77BA455@microsoft.com>

|>|>| X-Newsreader: Forte Agent 1.8/32.548

|>|>| MIME-Version: 1.0

|>|>| Content-Type: text/plain; charset=us-ascii

|>|>| Content-Transfer-Encoding: 7bit

|>|>| Newsgroups: microsoft.public.dotnet.framework.aspnet

|>|>| NNTP-Posting-Host: dyn-13-227.myactv.net 24.89.13.227

|>|>| Lines: 1

|>|>| Path:

|>TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl

|>|>| Xref: TK2MSFTNGXA01.phx.gbl

|>|>microsoft.public.dotnet.framework.aspnet:111583

|>|>| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

|>|>|

|>|>| Hi Leslie:

|>|>|

|>|>| Have you tried stepping through Application_Start with the

debugger?

|>|>|

|>|>| With Visual studio, set a breakpoint [1] in Application Start and

|>hit

|>|>| F5 to launch the debugger. There is also a whitepaper with some

|>links

|>|>| on using the debugger [2].

|>|>|

|>|>| You might also investigate Try / Catch blocks to handle the

|>exception

|>|>| and log it. You won't be able to get into Application_Error from

|>|>| Application_Start because the request processing hasn't started as

|>|>| yet, but you could still log the error.

|>|>|

|>|>| [1]

|>|>|

|>|>

|>

http://msdn.microsoft.com/library/default.asp?url" rel="nofollow" target="_blank">msdn.microsoft.com/library/default.asp=/library/en-us/vsdebug/htm

|>|>l/_asug_setting_breakpoints.asp

|>|>|

|>|>| [2]

|>|>|

|>|>

|>

msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi">msdn.microsoft.com/asp.net/using/migrating/phpmig/whitepapers/debuggi

|>|>ng.aspx

|>|>|

|>|>|

|>|>| --

|>|>| Scott

|>|>| www.OdeToCode.com/blogs/scott/">www.OdeToCode.com/blogs/scott/

|>|>|

|>|>| On Mon, 11 Jul 2005 15:43:03 -0700, Leslie

<mason@newsgroup.nospam>

|>|>| wrote:

|>|>|

|>|>|>I am attempting to handle errors by using Application_Error.

This

|>seems

|>|>to

|>|>|>work fine in most situations. However, if the exception occurs

|>during

|>|>the

|>|>|>Application_Start method, the stand error screen is displayed

and

|>my

|>|>custom

|>|>|>error handling in Application_Error does not run.

|>|>|>

|>|>|>Why does this occur, and is there something I can do to cause

|>|>|>Application_Error to be automatically invoked during an

|>|>Application_Start

|>|>|>exception?

|>|>|

|>|>|

|>|>

|>|>

|>|

|>

|

|

|



-