Geeks With Blogs
Austin's Pad Who's on first? .Net

I have recently been involved in an interesting debate whether to have development teams utilize Server.Transfer or Response.Redirect as the method of choice for transferring the user from 1 place in the application to another. 

One side debates Response.Redirect is not a scalable solution because of the performance hit it causes because it has to ask the client browser to please request this next page using a 302 header.  Which really, I think they should be using the point that Form and Query string variables are not persisted between pages using the Response.Redirect instead you have to stick information into Session which can be problematic in itself sometimes.  I have personally coded on some very large, high volume sites that use nothing but Response.Redirect and the application scaled just fine.

The other side debates that Server.Transfer is not user friendly because the page requested may not be the page that shows in the URL.  And, if the user hits the “Refresh” button then basically the code has to execute all the way from the page the user originally started from to the last page the actually viewed in the process.  Not to mention, the Microsoft bug where if you do a Server.Transfer(”page.aspx”, true) you will get an “Invalid ViewState” error.  Which may cause the developers to want to disable the enableViewStateMac which I personally don't think is a very good security practice.  Also, your application could potentially run into a “stack overflow” situation if a developer does a Server.Transfer to the same page.  It has been a while but I also think Server.Transfer doesn't invoke PrincipalPermissionAttribute security on the target page when transferring to it.

I am curious what other people in the ASP.Net community think about this.  I really have just summarized the conversations we had over this topic so please expect that I have missed some details.  Personally, I think both have pros and cons but with that they are also were created to meet different development needs for different situations.  So, locking it down and forcing a team of developers to use one way or the other for every situation is a recipe for disaster.

Posted on Wednesday, September 28, 2005 1:19 PM Asp.Net | Back to top


Comments on this post: Response.Redirect vs. Server.Transfer

# re: Response.Redirect vs. Server.Transfer
Requesting Gravatar...
Thanks for putting up the Pros and Cons
Left by REnuka Prasad on Jul 12, 2006 9:46 PM

# re: Response.Redirect vs. Server.Transfer
Requesting Gravatar...
Tried using server.transfer which had a great idea at first. Just didnt quiet work well due to the infamous ViewState Error. gave in to response.redirect which so far works very well.

Would like to use server.transfer, but too buggy at the moment. and way too many issues with it to consider.
Left by Chris on Dec 07, 2006 3:30 PM

# re: Response.Redirect vs. Server.Transfer
Requesting Gravatar...
Works great for the right situation!
Left by Bob on Feb 25, 2009 5:39 AM

# re: Response.Redirect vs. Server.Transfer
Requesting Gravatar...
You can find differences here


http://www.programcall.com/1/interview/difference-between-response-redirect-vs-server-transfer.aspx
Left by Reddy on Jun 03, 2011 6:26 AM

Your comment:
 (will show your gravatar)


Copyright © Chris Austin | Powered by: GeeksWithBlogs.net