Can some explain?http://forums.asp.net/t/294673.aspx/1?Can+some+explain+Fri, 01 Aug 2003 16:02:59 -0400294673294673http://forums.asp.net/p/294673/294673.aspx/1?Can+some+explain+Can some explain? Hi, I ran across an interesting dilema in a try.. catch.. block that uses &quot;response.Redirect()&quot; Can someone explain why the code below always goes to &quot;www.asp.net&quot;? It does this regardless of the value of intNumber. Am I not fully understanding something, I would have thought it would go to &quot;www.microsoft.com&quot;? <pre class="prettyprint">&lt;script runat=&quot;server&quot;&gt; Sub Page_Load Dim intNumber As Integer intNumber = 0 Try If intNumber &lt;&gt; 0 Then Response.Redirect( &quot;http://www.sqlteam.com&quot; ) Else Response.Redirect( &quot;http://www.microsoft.com&quot; ) End If Catch Response.Redirect( &quot;http://www.asp.net&quot; ) Finally Response.Write( &quot; Finally!&quot; ) End Try End Sub &lt;/script&gt;</pre> :) JB 2003-07-30T15:54:02-04:00294695http://forums.asp.net/p/294673/294695.aspx/1?Re+Can+some+explain+Re: Can some explain? Its going to exception as u just wrote Catch It should be <pre class="prettyprint">Catch ex as exception</pre> 2003-07-30T16:14:19-04:00294703http://forums.asp.net/p/294673/294703.aspx/1?Re+Can+some+explain+Re: Can some explain? Aaaaaahhhhhhhh, I thought it was some stupid I was doing. Thanks, JB 2003-07-30T16:17:59-04:00294716http://forums.asp.net/p/294673/294716.aspx/1?Re+Can+some+explain+Re: Can some explain? Hi again, Sorry but it still does the same with the new code. I should point out that if I take the &quot;Response.Redirect()&quot; out of the catch it works as I would think it should. Anyway, in the code below please tell me where I am wrong to think that this code should redirect to &quot;www.microsoft.com&quot;? <pre class="prettyprint">&lt;script runat=&quot;server&quot;&gt; Sub Page_Load Dim intNumber As Integer intNumber = 0 Try If intNumber &lt;&gt; 0 Then Response.Redirect( &quot;http://www.sqlteam.com&quot; ) Else Response.Redirect( &quot;http://www.microsoft.com&quot; ) End If Catch objEx As Exception Response.Redirect( &quot;http://www.asp.net&quot; ) Finally Response.Write( &quot; Finally!&quot; ) End Try End Sub &lt;/script&gt;</pre> JB 2003-07-30T16:24:12-04:00294785http://forums.asp.net/p/294673/294785.aspx/1?Re+Can+some+explain+Re: Can some explain? You may use &quot;objEx.Message&quot; to find out why. 2003-07-30T17:21:18-04:00294790http://forums.asp.net/p/294673/294790.aspx/1?Re+Can+some+explain+Re: Can some explain? If you just write response.write(objEx.message) or just catch.. with no code you'll find that the redirect goes to MS site 2003-07-30T17:25:58-04:00294812http://forums.asp.net/p/294673/294812.aspx/1?Re+Can+some+explain+Re: Can some explain? Hi folks, If I have the Response.Redirect() in the Catch Block than it always redirects to that url. If I remove it, it works fine. My question is, if there is no exception, which in this case there shouldn't be, than why is it doing whats in the catch block? Or is this normal? Try these 2 codes and see for yourself. <pre class="prettyprint">&lt;script runat=&quot;server&quot;&gt; Sub Page_Load Dim intNumber As Integer intNumber = 0 Try If intNumber &lt;&gt; 0 Then Response.Write(&quot;1&quot;) Else Response.Write(&quot;2&quot;) End If Catch objEx As Exception response.write(objEx.message) Response.Write(&quot;3&quot;) Finally Response.Write( &quot; Finally!&quot; ) End Try End Sub &lt;/script&gt;</pre> This returns "2 Finally!" as it should. Now try this... <pre class="prettyprint"> <%@ Page Language="VB" %> &lt;script runat="server"&gt; Sub Page_Load Dim intNumber As Integer intNumber = 0 Try If intNumber <> 0 Then Response.Redirect( "http://www.sqlteam.com" ) Else Response.Redirect( "http://www.microsoft.com" ) End If Catch objEx As Exception Response.Redirect( "http://www.asp.net" ) Finally Response.Write( " Finally!" ) End Try End Sub &lt;/script&gt; </pre> This redirects to &quot;www.asp.net&quot; exactly opposite of what the above code executes. Explain that please????????????? :) JB 2003-07-30T17:45:02-04:00295224http://forums.asp.net/p/294673/295224.aspx/1?Re+Can+some+explain+Re: Can some explain? JB, 1. I just posted a new thread asking for explaination. Follow it. <a href="http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217"> http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217 Catch me if you can? by try/catch/response.redirect. Need expert to explain. </a> 2003-07-30T23:10:24-04:00295235http://forums.asp.net/p/294673/295235.aspx/1?Re+Can+some+explain+Re: Can some explain? OK, I just posted an answer in your new thread: <a href="http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217#295233"> http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217#295233</a> 2003-07-30T23:23:24-04:00295243http://forums.asp.net/p/294673/295243.aspx/1?Re+Can+some+explain+Re: Can some explain? Bertrand, 1. Thanks, Still Catch me if you can? :-D It still did not work. 2. See the answers in the new thread. 2003-07-30T23:31:56-04:00295266http://forums.asp.net/p/294673/295266.aspx/1?Re+Can+some+explain+Re: Can some explain? Yes it does. Add the false on google redirect AND asp.net redirect... 2003-07-30T23:47:43-04:00295276http://forums.asp.net/p/294673/295276.aspx/1?Re+Can+some+explain+Re: Can some explain? JB, Bertrand, 1. It finally worked! :-D 2. See the other new thread for answer. Still, who would know that *ASP.NET trick* ? JB, What we need is Redirect(string, bool) of below point 2. MSDN: 1. Redirects a client to a new URL and specifies the new URL. [C#] public void Redirect(string); 2. Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate. [C#] public void Redirect(string, bool); 2003-07-30T23:58:45-04:00295433http://forums.asp.net/p/294673/295433.aspx/1?Re+Can+some+explain+Re: Can some explain? Hi All, This thread is not completed cleared in terms of explanation. So if any one want to give us an explanation, please consider having a look at this below thread already mentioned in previous post. Thanks. <a href="http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217">http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217 Catch me if you can? by try/catch/response.redirect. Need expert to explain. </a> 2003-07-31T04:34:17-04:00296366http://forums.asp.net/p/294673/296366.aspx/1?Re+Can+some+explain+Re: Can some explain? I posted someanswers there. Let me know if anything still looks mysterious. 2003-07-31T19:54:55-04:00297428http://forums.asp.net/p/294673/297428.aspx/1?Re+Can+some+explain+Re: Can some explain? 1. Can some explains? Finally... <a href="http://support.microsoft.com/default.aspx?scid=kb;[LN];312629"> PRB: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer Microsoft Knowledge Base Article - 312629 </a>2. Or see thread where we found above article: <a href="http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&amp;PostID=295217"> Re: Catch me if you can? by try/catch/response.redirect. Need expert to explain. </a> 2003-08-01T16:02:59-04:00