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)
'lblError.Text = "That order number has already had an RGA generated for it"
Else
lblError.Text = "That order number has already had an RGA generated for it"
'Response.Redirect("default.aspx?OrderNum=" & txtOrderNum.Text & "&ItemNum=" & txtItemNum.Text)
End If
Catch exp As Exception
'Response.Redirect("error.aspx")
Finally
objConn.Close()
objCMD.Dispose()
End Try

What woudl be the best way to handle this?
Thanks
0
awanvil
8/6/2003 12:35:48 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
1063 Views

Similar Articles

[PageSpeed] 35

Not too sure - but that may happen due to the fact that You don't clear your error ! Maybe there's kind of internal check for outstanding errors before redirect...

Could You pls give more infor on what exact error does occur ?
Regards.
0
Nobody
8/6/2003 1:14:53 PM
After doing a little research i found out the when you call response.redirect it also call response.end. This in effect ends the process, whith cause the error. If I put the false at the end of the statement this tells is not to use response.end and no error.
0
awanvil
8/6/2003 1:20:09 PM
Reply:

Similar Artilces:

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 dbReader.read() 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 > 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 in web form
Hi I have a try catch in a (web form) method..now I want to implement a finally and in this check if there are any exceptions thrown .. if yes I have to do some processing in the finally block.  My question is how can I check in Finally if there are any exceptions been thrown at all . Thanks Exceptions that are thrown will be caught in the catch block, so that is where you will process your exceptions. Finally is used for things such as closing database connections and disposing of objects.Ryan OlshanASPInsider | Microsoft MVP, ASP.NEThttp://ryanolshan.comHow to ask a qu...

How do I do a try catch for web form?
Hi, I do this all the time for windows forms, and I put this code into the code behind for web forms and I get no errors, but it doesnt work, is there a way to do a try catch for asp.net web forms? I use vb.net code behind, thanks! Try Cmd.ExecuteNonQuery() Catch ex As Exception MsgBox("Error: " & ex.message) End Try You cant use MsgBox in ASP.NET.. thats a winform thingy.. Use javascript alert() instead. ...

web.config
I'm working an a SSO project.  On all of the sites, the forms login url is the login website. (login.mydomain.com), I'm redirected to the login page fine, but the ReturnUrl is just the page name, so if I'm on www.mydomain.com/Test.aspx, the ReturnUrl = /Test.aspx, not http://www.mydomain.com/Test.aspx.  I though an easy fix would be to catch this redirect in the global.asax and modify the url that I'm redirecting to for login, but I can't seem to find how to do it.  I'm also up for a better solution if someone has a tried and proven one.  Th...

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?   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...

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...

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...

Response.Redirect within Try Catch
Hi, I am using asp.net 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 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: http://www.error-bank.com/microsoft.public.dotnet.languages.vb.1/190535_Thread.aspxDarrell 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....

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

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?      ...

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...

Forms Authentication
Hi I am creating a new Website Application that redirects the logged in user to a webpage based upon the role to which he belongs programatically in 'Authentication' event. I have designed the app. so that a User can belong to a single role at one time and I am using membership provider.  I have a web page that is stored in the rootfolder which is accessible by all users(including unauthenticated users). This webpage contains different menuitems and one of them is 'login'.  So If user A belongs to Role 'abc', he is redirected to a webpage in folder abc. S...

web form
I have a web form with some text boxes with validation to ensure that data has been entered. I have two buttons one for "submit" and one for "Return to main". When I click on submit - all works OK as it should with asking the user to enter data for the text boxes. However, when I click "Return to main", instead of redirecting to the main page, the validation requirements for the form appear. Here is some of my code... <table> <tr> <td valign="top" style="width: 318px"><asp:TextBox id="txtTextBox1" runat=&quo...

Web resources about - Try..Catch and Response.Redirect - asp.net.web-forms

Humanitarian response to the 2010 Haiti earthquake - Wikipedia, the free encyclopedia
The response to the 2010 Haiti earthquake included national governments, charitable and for-profit organizations from around the world which ...

Kohli's sledge response goes viral
He may have hit a run-a-ball 117, but it was Indian vice-captain Virat Kohli's response to a sledge by Australian bowler James Faulkner that ...

Tactical response group sent in to Kenwick domestic amid gun fears
FIREARM fears prompted police to call in the tactical response group during a domestic incident in one of Perth’s southeastern suburbs.

Australia v India: Virat Kohli's perfect response to James Faulkner sledge
... Virat Kohli made the history books when he registered his 24th century and 7000 runs in ODIs at the MCG on Sunday but it was his perfect response ...

Kohli's sledge response goes viral
He may have hit a run-a-ball 117, but it was Indian vice-captain Virat Kohli's response to a sledge by Australian bowler James Faulkner that ...

René Angélil's death draws strong response from fans, friends
... death has left friends and fans saddened and expressing their condolences to the family of international superstar of Céline Dion. Responses ...

eMotorWerks Now Involved In Demand Response With California Utilities
Originally published on EV Obsession. All 3 major investor-owned utility companies in California have awarded demand response contracts to the ...

Trump On Nikki Haley’s SOTU Response: I AM Angry
Trump On Nikki Haley’s SOTU Response: I AM Angry

Bring your own thermostat demand response programs represent a target market of US$1.4 billion, says ...
Since 2012, utilities across the United States have been piloting bring your own thermostat (BYOT) demand response (DR) programs, supplementing ...

RTI certificate course gets overwhelming response
RTI certificate course gets overwhelming response - Around 75 forms were given; we could take only 50 students. The response was beyond our expectation, ...

Resources last updated: 1/20/2016 6:05:32 AM