response.redirect inside a Try Catch...

I’ve come across a situation where I have a response.redirect inside a TRY Catch

The redirect seams to trigger an exception.


I found a work around but I’m scared it might cause other problems.


Response.redirect(“blah blah”, False)    ß the false seams to help … although I’m not 100% sure why …


You guys see any problem in this solution?


9/15/2008 12:31:16 PM 91979 articles. 4 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 11

It should be ok. The second argument means whether the execution of the current page should be stopped or not. When you specified false, it means if should not stop and thus no error otherwise previosly it was being stopped in the middle of executing.

Let Me Google That For You!
9/15/2008 12:40:17 PM

 Best way to get around this is to declare a variable called url, wherever you have response.redirect(www.....) replace it with url="www....." and add the following code outside your try catch at the end

if url <> nothing then


end if 



Please mark this post as Answered if my comment helped you, thanks.
9/15/2008 12:42:49 PM

Thanks guys, both make a valuable point and it's helped me out.

9/15/2008 12:49:13 PM

Similar Artilces:

Response.Redirect inside a Try Catch block
Can you put a Response.Redirect inside a Try Catch block?I think you will get a thread Abored Error, true? Who said so? I just tried it and it worked fine!!!!What is mainly the problem you are facing?RegardsBilal Hadiar, MCP, MCTS, MCPD, MCTMicrosoft MVP - Telerik MVP...

try catch finally / response.redirect / response.end flow control question
Hi Guys, Can any one tell me if the finally block would be executed in the following example (assuming that returned false because no records were found).   Many Thanks! DanielTry dbCon = New SqlConnection(myconnectionstring) dbCon.Open() dbCom = dbCon.CreateCommand() strSQL + "SELECT * FROM bookings WHERE ID &gt; 9000" dbCom.CommandText = strSQL dbReader = dbCom.ExecuteReader() If dbReader.Read() Then 'init fields Else Response.Redirect("main.aspx") End if Finally dbReader.clo...

Try..Catch and Response.Redirect
I have sub that connect to a db to verify users. If the user is cleared the they are redirected to the next page and if not then they are forced to login again. I have noticed that during debug on my Try..Catch..Finally block an error is always fired on the resposne.redirect. Dim rs As SqlDataReader = objCMD.ExecuteReader If rs.Read() = False Then Response.Redirect("issuenewrga.aspx?OrderNum=" & txtOrderNum.Text & "&ItemNum=" & txtItemNum.Text & "&LineNum=" & txtLineNum.Text) ...

Try catch, Response.Redirect, and endResponse
 Hi,I get an error email from this aspx page once a while. I have pasted the code skeleton below. The error email says the error occured at the line marked *, where sproc1 is being called. When I look up the database table, I see the sproc2 has been executed as well. I created a test page and changing the endResponse parameter to true or false did not make any difference, when an exception occurs the execution always jumps straight to the catch block. I wish the same thing was happening in the production page as well, but the sproc2 is always being called.try{    .....&nb...

Redirect inside Try-Catch-Finally?
Hi all, I was told that the "finally" code always executes. Would that be true for the code below. Note that if the 'try' is successful -- and the a redirect occurs -- will the "finally' happen. I'd hate to leave the connection open. Basically, I'm trying to read from a db, write a cookie, and sen the user elsewhere. Thanks.             try            {              &nbs...

Response.Redirect and Try Catch Finally
If I have a Try Catch Finally block with a Response.Redirect in the Catch and a Connection.Close in the Finally, will the code in the Finally still execute before the Redirect takes place? Someone asked a similar question at this web site: Norton, MVPDarrell Norton's BlogPlease mark this post as answered if it helped you! Thanks for the link. Can anyone confirm that, yes, the Finally will execute? Yes,it will execute....

try, catch, Response.Redirect problem
Hi,This is the code which makes me a problem: try{ Response.Redirect("SomePage.aspx");}catch{ ...someOperation():} It always goes to catch region...  i think you don't have that page in your web server. check it first.Got what you needed. Please mark as answer. This is a known issue, try to use the below code try {Response.Redirect("WebForm2.aspx",false);     }catch(Exception ex) { Response.Write(ex.Message); } HCHaissam Abdul MalakMCAD.NET| Blog | Sathesh_pandian:i think you don't have that page in your we...

Response.Redirect within Try Catch
Hi, I am using 2.0 and I have a page where I need to use the Try-Catch-Finally structure. Within the Try statement I have various commands and then at the end of it I have a Response.Redirect("....") to take the user to another page. Within my catch statement I also have a Response.Redirect("../errorPage.htm") which will take you to the error page if any exceptions occur. However, I have tested the page and I know there are no exceptions happening but the user is still getting redirected to the error page.  Is there anyway to make this not happen? I am using Smart Navigatio...

Response.redirect without exception in a try catch?
I have these code: try{ if(!fuFaxnummer.PostedFile.FileName.EndsWith(".csv")){ Response.Redirect("faxnummerimport.aspx?ID=" + id + "&msg=2"); } //code to execute when the file is a .csv } catch (exception ex){ LogDA.insertLog(...); Response.Redirect("error.aspx"); }I know that "Response.Redirect" gives an Exception. When I set the bool endResponse at false (Response.redirect("",false)) there is no exception BUT he execute the code behind my IF(). Someone with a solution?      ...

Delete command in GridView with response.redirect in a try catch
 Hi, I have these code: protected void gvFaxLijst_RowCommand(object sender, GridViewCommandEventArgs e){try{if (e.CommandName == "Delete"){//codeResponse.write("index.aspx",false);}}catch(exception ex){insertlog(...);Server.Transfer("error.aspx");}The problem is that the Delete command isn't finished so I got an error (System.Web.HttpException)When i remove the False in Response.write("index.aspx") then I got these error:  [System.Threading.ThreadAbortException] = {Unable to evaluate expression because the code is optimized or a...

problem with Try and Catch "Response.Redirect ....."
If the try is succesfull it will also go to "2.aspx", any idea what is wrong with it? I tried remove the line of redirection to page 2.aspx. It works...if no error, it will go to 1.aspx. But when I include the Catch line. It will direct it to 2.aspx, eventhough there is no error... Try ------ ------ ------ Response.redirect("1.aspx") Catch Response.redirect("2.aspx") End Try Can you supply the try-catch code ?"I would love to change the world, but they won't give me the source code." -unknown Try SmtpMail.Send(msg) msg...

trying to get started and i am getting this error
when i go to, i get: DotNetNuke Upgrade Error The Assembly Version ( [ASSEMBLYVERSION] ) does not match the Database Version ( [DATABASEVERSION] ) ERROR: Could not connect to database. Could not find file 'd:\hosting\nmoran26\Providers\DataProviders\AccessDataProvider\DotNetNuke.mdb'. Any suggestions will be appreciated. Thanks, Nicole Do you have a username and password set on your database? Make sure you follow the steps mentionned in the Readme.txt located in the documentation folder. In any case make sure your credentials for yo...

.NET 2005 TRY..CATCH with SQL RAISERROR Not Catching
Is there a reason why the following code does not raise an error in my .NET 2005 application? Basically I have a try..catch in my stored procedure. Then I have a try...catch in my .NET application that I want to display the error message. But, when the stored proc raisses the error, the .net code doesn't raise it's error. The .NET code DOES raise an error if I remove the try..catch from the SQL proc and let it error (no error handling), but not if I catch the error and then use RAISERROR to bubble-up the error to .NET app. (I really need to catch the error in my SQL proc and rollbac...

How to catch page not found when redirecting using response.redirect.
There is a virtual path(http://server1/files/test.xls). From web app, I have to redirect to above path. If test.xls does not exist in the path, I have to display unauthorized page. I tried using if (File.Exists(Server.MapPath(URL))) but it gives an error "it is not a valid virtual path". Please help.If this answered your question, please mark as an answer so others will know too. you can do a default redirect on a 404 by setting it in the web.config <customErrors mode="RemoteOnly" defaultRedirect="~/Misc/ErrorPage.aspx">    &n...

Web resources about - response.redirect inside a Try Catch... -

Frequency response - Wikipedia, the free encyclopedia
Frequency response is the quantitative measure of the output spectrum of a system or device in response to a stimulus, and is used to characterize ...

Miss Colombia had an incredibly graceful response after being mistakenly crowned Miss Universe
If a pageant queen is measured for her grace under pressure, then Miss Colombia is still a winner. On Sunday night, Miss Colombia Ariadna Gutierrez ...

Two Fatally Shot By Chicago Police In Response To Domestic Disturbance On West Side
Police were called to an apartment building on the 4700 block of West Erie at about 4:30 a.m. Saturday for a domestic incident.

The Correct Response To Holiday Attire
Submitted by: (via nessy1 ) Tagged: christmas , tie , no , Cats Share on Facebook

Kurt Russell's Blunt Response To The Guardians Of The Galaxy 2 Casting Rumors
Last week, it was reported that Kurt Russell is being considered by Marvel to play Peter Quill’s father in Guardians of the Galaxy Vol. 2 . Here’s ...

NYU Divest Sit-in Has Immediate Response
... and alumni, who are all calling on the New York University (NYU) to divest from fossil fuels, [&hellip NYU Divest Sit-in Has Immediate Response ...

Home Alone's Daniel Stern Has Hilarious In Character Response To Macaulay Culkin
Earlier this month, Macaulay Culkin set the Internet on fire by releasing a video where he played [...]

Axelrod: Obama Was ‘Tone-Deaf’ In His Response To Terrorist Attacks
Axelrod: Obama Was ‘Tone-Deaf’ In His Response To Terrorist Attacks

Test Tube News: Tools Nations Use in Response to Terror Attacks
An act of terrorism can stop a country in its tracks and lead to citizens being stripped of their rights. What do countries usually do after ...

Resources last updated: 12/26/2015 8:52:51 PM