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.
<script runat="server">
Sub Page_Load
Dim intNumber As Integer
intNumber = 0
Try
If intNumber <> 0 Then
Response.Write("1")
Else
Response.Write("2")
End If
Catch objEx As Exception
response.write(objEx.message)
Response.Write("3")
Finally
Response.Write( " Finally!" )
End Try
End Sub
</script>
This returns "2 Finally!" as it should.
Now try this...
<%@ Page Language="VB" %>
<script runat="server">
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
</script>
This redirects to "www.asp.net" exactly opposite of what the above code executes. Explain that please????????????? :) JB
John Belthoff
Dodge, Duck, Dip, Dive & Dodge
If a man can dodge a wrench, he can dodge a ball!
JBelthoff
Member
553 Points
135 Posts
Re: Can some explain?
Jul 30, 2003 05:45 PM|LINK
<script runat="server"> Sub Page_Load Dim intNumber As Integer intNumber = 0 Try If intNumber <> 0 Then Response.Write("1") Else Response.Write("2") End If Catch objEx As Exception response.write(objEx.message) Response.Write("3") Finally Response.Write( " Finally!" ) End Try End Sub </script>This returns "2 Finally!" as it should. Now try this...<%@ Page Language="VB" %> <script runat="server"> 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 </script>This redirects to "www.asp.net" exactly opposite of what the above code executes. Explain that please????????????? :) JBDodge, Duck, Dip, Dive & Dodge
If a man can dodge a wrench, he can dodge a ball!