How do I properly use: Response.Redirect("/webpagename.html")

trend

Centurion
Joined
Oct 12, 2004
Messages
171
I am having this issue...

I have a login form that when users post information to, it will (of course) validate the information.. and based on that information it will either:
A)Response.Redirect("Access.asp")
B)Response.Redirect("/NoAccess.asp")

My problem is.. everytime I do a response.redirect.. My vb.net/asp.net code doesn't like it.. The thread reports "Thread was being aborted." in my logs

(My response.redirects are in a try of a try/catch and the catch logs the error being "Thread was being aborted." everytime either response.redirect are executed (aka if the user is valide or is not doesn't matter).

Any ideas? I don't think javascript redirects are normal for this... So should I just not worry about and not report the "Thread was being aborted." because this is normal (or is it?)?


thanks!
Lee
 
You will get the thread aborted exception if there is any code following your Response.Redirect, if you search these forums you should find further information on this problem.
 
Thank you for your quick reply.

Yeah, thatis what i figured :/

I was conteplating doing it like this gentelmen suggested:

Visual Basic:
'After your connection openned
Dim bTest1, bTest2 as Boolean
Dim pageRedirect as String
pageRedirect = "default.aspx"  
If( Not bTest1 ) Then
pageRedirect = "fail1.aspx"
End If
If( Not bTest2 ) Then
pageRedirect = "fail1.aspx"
End If
'and so on...
'Close your connection here.
Response.Redirect( pageRedirect )

But if this code is in a function called by another function.. it would still case an issue, am I right?

Is there a better way to do this?

thanks

Lee
 
Hmm, my other 2 thoughts were:
1) use Server.Transfer()
2) use a timer... but could timers even be used with webpages? (well outside of javascript that is)
 
Back
Top