Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Try Catch and Finally

Reply
Thread Tools

Try Catch and Finally

 
 
Alfredo
Guest
Posts: n/a
 
      08-11-2005
Hi,

I have question, i debug this code:

try
'Some operations
catch
Response.Redirect("Page 1")
finally
Response.Redirect("Page 2")
end try

I am getting an error but always Page 2 is loaded. Why?

Thanks,

Alfredo Barrientos

 
Reply With Quote
 
 
 
 
Marina
Guest
Posts: n/a
 
      08-11-2005
Because the Finally block always executes no matter if the try part
succeeded or not.

"Alfredo" <> wrote in message
news: oups.com...
> Hi,
>
> I have question, i debug this code:
>
> try
> 'Some operations
> catch
> Response.Redirect("Page 1")
> finally
> Response.Redirect("Page 2")
> end try
>
> I am getting an error but always Page 2 is loaded. Why?
>
> Thanks,
>
> Alfredo Barrientos
>



 
Reply With Quote
 
 
 
 
Curt_C [MVP]
Guest
Posts: n/a
 
      08-11-2005
Alfredo wrote:
> Hi,
>
> I have question, i debug this code:
>
> try
> 'Some operations
> catch
> Response.Redirect("Page 1")
> finally
> Response.Redirect("Page 2")
> end try
>
> I am getting an error but always Page 2 is loaded. Why?
>
> Thanks,
>
> Alfredo Barrientos
>


try a throw or break, but the idea is that the FINALLY will always fire.
Also, look at the Response.Redirect() it has some extra props to stop
execution, perhaps that will work for you.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com
 
Reply With Quote
 
Grant Merwitz
Guest
Posts: n/a
 
      08-11-2005
The way the Catch statement works is:

1) TRY run the code in the Try part

2) If an exception occurs, run code in the Catch Part.

3) FINALLY , run code in the Finally part.

So no matter what happens, that finally will always run.

"Alfredo" <> wrote in message
news: oups.com...
> Hi,
>
> I have question, i debug this code:
>
> try
> 'Some operations
> catch
> Response.Redirect("Page 1")
> finally
> Response.Redirect("Page 2")
> end try
>
> I am getting an error but always Page 2 is loaded. Why?
>
> Thanks,
>
> Alfredo Barrientos
>



 
Reply With Quote
 
=?Utf-8?B?U3JlZWppdGggUmFt?=
Guest
Posts: n/a
 
      08-11-2005
Finally is always executed at the end.. whether there was an exception or
not..


http://msdn.microsoft.com/library/de...ogether_PG.asp



"Alfredo" wrote:

> Hi,
>
> I have question, i debug this code:
>
> try
> 'Some operations
> catch
> Response.Redirect("Page 1")
> finally
> Response.Redirect("Page 2")
> end try
>
> I am getting an error but always Page 2 is loaded. Why?
>
> Thanks,
>
> Alfredo Barrientos
>
>

 
Reply With Quote
 
Marc Robitaille
Guest
Posts: n/a
 
      08-11-2005
Try
'Some operations

Response.Redirect("Page 2")

Catch
Response.Redirect("Page 1")

End Try()

"Alfredo" <> a écrit dans le message de news:
. com...
> Hi,
>
> I have question, i debug this code:
>
> try
> 'Some operations
> catch
> Response.Redirect("Page 1")
> finally
> Response.Redirect("Page 2")
> end try
>
> I am getting an error but always Page 2 is loaded. Why?
>
> Thanks,
>
> Alfredo Barrientos
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      08-11-2005
What they all said.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Everybody picks their nose,
But some people are better at hiding it.

"Sreejith Ram" <> wrote in message
news:05F01E74-6C9E-4B7D-9A31-...
> Finally is always executed at the end.. whether there was an exception or
> not..
>
>
> http://msdn.microsoft.com/library/de...ogether_PG.asp
>
>
>
> "Alfredo" wrote:
>
>> Hi,
>>
>> I have question, i debug this code:
>>
>> try
>> 'Some operations
>> catch
>> Response.Redirect("Page 1")
>> finally
>> Response.Redirect("Page 2")
>> end try
>>
>> I am getting an error but always Page 2 is loaded. Why?
>>
>> Thanks,
>>
>> Alfredo Barrientos
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
try catch finally to close and dispose, but still wantApplication_error to fire jobs ASP .Net 5 11-17-2007 01:50 PM
Try...Catch...Finally not firing finally? David Lozzi ASP .Net 12 05-11-2007 12:41 AM
Try Catch Finally and Threads Wayne ASP .Net 2 06-07-2006 12:49 AM
The problem with Try Catch Finally... VB Programmer ASP .Net 23 08-15-2003 01:55 PM
Question: Try,Catch,Finally VB Programmer ASP .Net 1 08-07-2003 07:27 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57