Hi, I ran across an interesting dilema in a try.. catch.. block that uses "response.Redirect()" Can someone explain why the code below always goes to "www.asp.net"? It does this regardless of the value of intNumber. Am I not fully understanding something, I
would have thought it would go to "www.microsoft.com"?
<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
Response.Redirect( "http://www.asp.net" )
Finally
Response.Write( " Finally!" )
End Try
End Sub
</script>
:) JB
John Belthoff
Dodge, Duck, Dip, Dive & Dodge
If a man can dodge a wrench, he can dodge a ball!
Hi again, Sorry but it still does the same with the new code. I should point out that if I take the "Response.Redirect()" 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 "www.microsoft.com"?
<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>
JB
John Belthoff
Dodge, Duck, Dip, Dive & Dodge
If a man can dodge a wrench, he can dodge a ball!
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
Can some explain?
Jul 30, 2003 03:54 PM|LINK
<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 Response.Redirect( "http://www.asp.net" ) Finally Response.Write( " Finally!" ) End Try End Sub </script>:) JBDodge, Duck, Dip, Dive & Dodge
If a man can dodge a wrench, he can dodge a ball!
SushilaSB
Star
11417 Points
2265 Posts
Re: Can some explain?
Jul 30, 2003 04:14 PM|LINK
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb
JBelthoff
Member
553 Points
135 Posts
Re: Can some explain?
Jul 30, 2003 04:17 PM|LINK
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 04:24 PM|LINK
<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>JBDodge, Duck, Dip, Dive & Dodge
If a man can dodge a wrench, he can dodge a ball!
JimmyM
Star
8796 Points
1671 Posts
Re: Can some explain?
Jul 30, 2003 05:21 PM|LINK
SushilaSB
Star
11417 Points
2265 Posts
Re: Can some explain?
Jul 30, 2003 05:25 PM|LINK
Visual ASP/ASP.NET MVP
http://weblogs.asp.net/sushilasb
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!
Phuoc
Participant
1150 Points
230 Posts
Re: Can some explain?
Jul 30, 2003 11:10 PM|LINK
and where there is a team, there is more than one way.
bleroy
All-Star
15617 Points
2302 Posts
Re: Can some explain?
Jul 30, 2003 11:23 PM|LINK
----
This posting is provided "AS IS" with no warranties, and confers no rights.
Phuoc
Participant
1150 Points
230 Posts
Re: Can some explain?
Jul 30, 2003 11:31 PM|LINK
and where there is a team, there is more than one way.