473,320 Members | 1,865 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,320 software developers and data experts.

Response.Redirect Where to put it?

Hello,

I have a question about ASP.NET process. In this case:

Try
'SOME CODE

Response.Redirect("some_asp_page.aspx")
Catch obj_Exception as Exception
Throw obj_Exception
Finally
If Not (obj_Conn Is Nothing) Then obj_Conn.Dispose()
End Try

I wonder if ASP.NET reaches the finally part of the code or does it redirect
and neever reaches the finally statement?
Or should write something like this?

Try
'SOME CODE

Catch obj_Exception as Exception
Throw obj_Exception
Finally
If Not (obj_Conn Is Nothing) Then obj_Conn.Dispose()
Response.Redirect("some_asp_page.aspx")
End Try

Which one should I use?

Thanks in advance?

Henry
Nov 18 '05 #1
1 1380
The finally code will always get executed, so the first case is fine.
Interstingly enought your catch code will also get reached 100% of the time.
Response.Redirect throws a ThreadAbordException, so your code in the try{}
block will always throw an exception, which will be caught and rethrown by
your catch, and your finally will clean up. Since the thread is aborted,
everything works fine..so it's ok....but it is pretty interesting :)

On a side note, you probably don't want to rethrow the exception, consider
replace your catch code with:

Catch obj_Exception as Exception
Throw

which, instead of throwing an exception of type Exception with an
innerException of the actual type, will actually throw the original
exception with all the juicy information readily available. Check out:
http://dotnetguy.techieswithcats.com...s/004118.shtml for a better
explenation (if you are interested)

Karl

"Henry" <m3***********@hotmail.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
Hello,

I have a question about ASP.NET process. In this case:

Try
'SOME CODE

Response.Redirect("some_asp_page.aspx")
Catch obj_Exception as Exception
Throw obj_Exception
Finally
If Not (obj_Conn Is Nothing) Then obj_Conn.Dispose()
End Try

I wonder if ASP.NET reaches the finally part of the code or does it redirect and neever reaches the finally statement?
Or should write something like this?

Try
'SOME CODE

Catch obj_Exception as Exception
Throw obj_Exception
Finally
If Not (obj_Conn Is Nothing) Then obj_Conn.Dispose()
Response.Redirect("some_asp_page.aspx")
End Try

Which one should I use?

Thanks in advance?

Henry

Nov 18 '05 #2

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

Similar topics

3
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
4
by: JC | last post by:
Hi, I have a simple question regarding the Response.Redirect method. Does the server stop processing the ASP code as soon as it encounters the Redirect command? Or does it ever continue to...
4
by: TomT | last post by:
Hi.. I'm redirecting users to another page using: response.redirect("newpage.asp") this works... But I need to add a variable to the page specified.. IE: newpage.asp?id=JobID
6
by: Sam | last post by:
I have some issues with HTTP Headers and I was hoping for some pointers or references to good articles. Here is the problem. I have 6 .aspx pages, each page contains a common .ascx. This ascx...
3
by: Sehboo | last post by:
On my ASP page, when I click a button, I want to do three things: 1. Check for some values. 2. Open a new window and pass some values as query string. 3. Redirect to some other page Here...
13
by: Tim | last post by:
Hello, Is there a way to "cancel" a response.Redirect? For example, in the code below, could I insert anything in the Catch statement that would cancel the redirect and resume flow after the...
10
by: Niggy | last post by:
I get an error - any help appreciated. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
4
by: mike.biang | last post by:
I have an ASP page that is using an XMLHTTP object to request various pages from my server. I keep a single session throughout the XMLHTTP requests by bassing the ASPSESSIONID cookie through the...
9
by: RN1 | last post by:
When a server encounters the line Response.Redirect("abcd.asp") in a ASP script, the server tells the browser that it has to be redirected to another page (which is abcd.asp, in this case)....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.