Page 1 of 1
Redirect Pages: Your thoughts on the good & the bad please.
Posted: Thu Oct 02, 2008 3:33 pm
by JAB Creations
I'm curious as to people's thoughts on using redirect pages. Specifically in example when signing in/out of an account, registering, posting a thread, etc. Why would you and would you not want to use redirect pages?
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Thu Oct 02, 2008 6:23 pm
by alex.barylski
Well depending on your architecture/framework you have two options:
1. Redirect (Native to HTTP)
2. Request Forwarding (various depending on framework)
I use redirects when I know that a user invoked refresh would cause problems, such as after submitting a form. I redirect to a new *clean* URL and that way if a user hits refresh nothing gets double posted.
In almost every other situation I use a forward to save my server the hassle of HTTP redirection. Plus it comes in handy for implementying POSTBACK without hacking the $_POST variables or using sessions.
Obviously external URL's must be redirected, so that too is another condition.
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Thu Oct 02, 2008 6:59 pm
by josh
Right, I'd like to see another good use case for redirects besides the refresh issue hockey pointed out, if you're needing to redirect around to invoke parts of your program, you might want to look at why those parts can't be called in on the original page... redirects should also be used for things like 404s, exceptions, etc..
Basically the same rule of thumb as exceptions, don't rely on them for regular functionality, use them for exceptional functionality ( the refresh issue is an exception due to the design of the web )
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Fri Oct 03, 2008 2:28 pm
by alex.barylski
redirects should also be used for things like 404s, exceptions, etc..
I personally prefer showing my users an error message for 404...but why would you redirect on an exception?
I participated in a disscussion on exceptions a while back...it got quite lengthly so I won't get into that again but...why would you redirect on an exception?
I now use exceptions to propagate error messages (bubble up) until they can be handled/rendered by the view layer for display to the user. Redirecting seems...I dunno. Where would you redirect to?
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Fri Oct 03, 2008 2:31 pm
by josh
Log the exception, redirect to some alternative screen. In most cases you'd forward but I'm thinking more special use like an AJAX post or something, I don't know I'm just saying you may still want to redirect for weird reasons from time to time, but most of the time if you can't do what you want with a forward it seems like that'd be indicative of a bad design
Also some people want 404 traffic to hit their homepage, why let that traffic not convert because whoever linked to you used the wrong scheme, treat it as a 404 still but redirect users to actual content
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Fri Oct 03, 2008 3:04 pm
by alex.barylski
Ideally when someone encounters a 404 error I want them to have a mini-search displayed, showing them likely matches or maybe even the link to original document which has been relocated.
Log exceptions? I did do that for ages...then after that disscussion...I changed my mind about exceptions and began using them as message transporters, both user land errors and system errors -- the latter is what exceptions are usually advertised as -- especially when people say "Use them in exceptional situations" which I my self was guilty of saying.
I think the term "exception" is what is most confusing...I really wish they would find a better name considering their applicability.
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Fri Oct 03, 2008 5:39 pm
by josh
Well I think what is key is for every design guideline there's going to be an exception, use redirects when a redirect makes sense to you ( whether its fixing a loophole in form posting, or whatever ), not as a replacement for dispatching programming actions.
Also if you want the URL to match the action thats being dispatched, a redirect makes more sense then a forward. If the URL says /view/user and then mid processing of the user you decide you want them to see another screen then the "view" screen ( maybe edit ), it may make more sense to entirely redirect them to a new URL, even if all that redirect is going to do is switch the view. It just depends on your requirements
I think the key rule of thumb is use the redirect to improve the user experience, not delay it, and write it in such a way you wouldn't have to use a redirect if you change your mind about it later
Re: Redirect Pages: Your thoughts on the good & the bad please.
Posted: Fri Oct 03, 2008 10:43 pm
by alex.barylski
Agreed
