ServerTransfer vs ResponseRedirect

ServerTransfer vs ResponseRedirect

 Use Server.Transfer. whereever it is possible, use the Server.Transfer method instead of the Response.Redirect method.
Response.Redirect sends a response header to the client that causes the client to send a new request to the redirected server by using the new URL.
If you have tools installed like fiddler you can easily see what has been posted back inside Header to the clients like IE.
Its a Status code 302 and header contains location of resource.

 Server.Transfer avoids this level of redirection by simply making a server-side call.
You cannot always just replace Response.Redirect calls with Server.Transfer calls because Server.Transfer uses a new handler during the handler phase of request processing.
If you need authentication and authorization checks during redirection, use Response.Redirect instead of Server.Transfer because the two mechanisms are not equivalent and
as you know during authontication we check wheather cookie exists in Request or not. There we must use Response.Redirect.

When you use Response.Redirect, ensure you use the overloaded method that accepts a Boolean second parameter, and pass a value of false to ensure an internal exception is not raised.

You can see that exception by simply putting Try catch Blocks in your application. To avoid internal exception pass second parameter as false.

Also note that you can only use Server.Transfer to transfer control to pages in the same application. To transfer to pages in other applications, you must use Response.Redirect.

That means you can't call the pges residing outside of your application domain. like
http://bing.com  http://google.com www.asp.net can't put inside your server.transfer method.

Satalaj

Tags:

CSS Padding Vs Margin CSS Margin Vs PaddingLCD Vs LED Vs (Edge Led) Televisions..net String vs stringC# ref Vs outDateTime.Today Vs DateTime.NowHttp Vs. Httpsdelete vs truncateLinq to SqlRead Write MemoryStreamAsp.net Convert Image To Base64Connection Pooling

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.