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? 
  

 
 

0
DoaX
1/3/2008 3:51:39 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

2 Replies
759 Views

Similar Articles

[PageSpeed] 22

maybe you can tell us what you are trying to do?  I am not understanding your question...

response.redirect is a function and does not have an exception unless you specify within an if statement...

you can use response.redirect("gohereORthere") without a try catch block if you want


Remember to "Mark As Answer" if this post has helped you! Thanks....
And I say unto you, Ask, and it shall be given you; seek, and ye shall find; knock, and it shall be opened unto you...
LK 11:9
http://adventwebdesign.net
0
revkev
1/3/2008 4:02:57 PM

If the exception is a ThreadAbortException then it is a known issue.

Check below link for information on this kind of exception and how to solve it

http://dotnetjunkies.com/WebLog/shaunakp/archive/2005/02/15/54439.aspx

HC 


Haissam Abdul Malak
MCAD.NET
| Blog |
0
Haissam
1/3/2008 4:40:25 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...

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

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

difference between try{}catch{} and try{}catch(exception ex){}
Can any one explain the difference between try{}catch{} and try{}catch{Exception ex){}also in the following blocks,How we can know what exceptions we need to catch?try{}catch{SpecificException1 ex){}catch{SpecificException2 ex){} I will let you read the following articles:http://msdn.microsoft.com/en-us/library/0yd65esw(VS.80).aspx http://www.codersource.net/asp_net_exception_handling.aspx Regards,Vinz"Code, Beer and Music" that's my way of being a programmer!How to get your Forum Question Answered | Blog | CodeASP.NET if u give try {} catch(Exception ex){} then it wil...

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

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

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

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

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

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 - Response.redirect without exception in a try catch? - asp.net.web-forms

Motor vehicle exception - Wikipedia, the free encyclopedia
The exception is based on the idea that there is a lower expectation of privacy in motor vehicles due to the regulations they operate. Additionally, ...

Podcast #42 – It’s The Exception That Proves The Rule
... Language and Usage , which was frustrated by the high number of certain types of questions that were coming in. Is this podcast the exception ...

RWW News: Marco Rubio Reiterates His Opposition To Rape Or Incest Exceptions - YouTube
http://www.rightwingwatch.org/content/marco-rubio-reiterates-his-opposition-rape-or-incest-exceptions Right Wing Watch reports on the extreme ...

Why Kevin Pietersen is the exception to the No Dickhead Rule
Something fascinating is going on in English cricket at the moment.

John Lomax 'gutted' for Issac Luke, but says finals no exception to rules
... missing a grand final to a 10-game suspension, but says the NRL judiciary must maintain consistency in its rulings and cannot make exceptions ...

India becomes the exception to US nuclear ban
President George Bush has agreed to share civilian nuclear technology with India, reversing decades of US policies designed to discourage countries ...

Is Richard Umbers, Bernie Brookes' replacement as Myer CEO, an exception?
Myer's CIO was recently elevated to the top job, but he's in a very small minority.

Men Need to Admit That Jian Ghomeshi Is No Exception
That men like Jian Ghomeshi are a terrible exception and if we as men simply stand up and say we are not as bad as that, or that we are not rapists ...

China, Thailand reach visa exception agreement
China, Thailand reach visa exception agreement People's Daily Online ... this at a forum on China's foreign diplomacy held in Beijing. Both ...

No exception allowed in graft crackdown: People's Daily
No exception allowed in graft crackdown: People's Daily - Ecns.cn ecns The expulsion of Ling Jihua from the Communist Party of China (CPC) ...

Resources last updated: 11/28/2015 2:54:17 AM