Server.Transfer() and Response.Redirect()


  • Server.Transfer() directly transfers to the another page without round-trip back to the server, saving server resources.
  • When we are using Server.Transfer() original url remains same at adddress bar while page is getting changed ( so might be confusing for some times ) so URL History of the page is not chnaged.
  • We can’t use server.transfer() for the pages/sites which are not located on the server, we can use Server.Transfer() only for the pages on the same server.
  • We can only transfer on aspx pages using Server.Transfer() ,not html/htm pages.
  • We can also maintain state while using server.Transfer using HttpContext.Current , we can put/store values to
  • HttpContext.Current.Items[] Dictionary and we can access those values on the next page where we are transferred

HttpContext.Current.Items[“GeneratedQry”] = “Select * from XYZ”;


and we can access it on next page as

string SqlQry = Context.Items[“GeneratedQry”].ToString();

  • Server.Transfer() is having one more overload with parameter preserveForm , which is when true preserve the QueryString & Form collections;and when false clear the QueryString and Form collections.
  • If preserveForm is true and enableViewStateMac of page is also true then Exception “View State Is Invalid” is getting raised. Because ,When enableViewStateMac is true, ASP.NET runs a message authentication check on the view state of the destination page when the page is posted back from the client and the check will fail. For security purposes, you should keep the enableViewStateMac attribute set to true

Ref – MSDN SupportMSDN


  • Response.Redirect() is request from browser for the resource ( the page mentioned ). AS it is request from browser, if the mentioned page is available at the location then browser will generate new request to load the page mentioned causing the 2 server round trips, eventually increase load on server.
  • Response.Redirect is slower than Server.Transfer() due to extra server trip.
  • When we are using Response.Redirect() we can the new URL changes at adddress bar while page is getting changed as it is actually sever request for the page change or access so URL history of the page changes.
  • Using Response.Redirect we can redirect to the page on the different Server also.Response.Redirect can transfer both html & aspx file types.
  • Response.Redirect is GET request,so we cant post data from first page to next page , we can maintain state using queryString while using Response.Redirect()

Response.Redirect(“RedirectTest.aspx?ID=” + UserData.UserID));

and we can access it like

string userID = Request[“ID”];

  • Response.Redirect is also having one overload with Boolean as an extra parameter

public void Redirect (string url, bool endResponse) when true,

Redirects a client to a new URL. Specifies the new URL and whether execution of the current page should terminate.

  • As Response.Redirect is as such new page request for system, it automatically applies all the authentication and authorization logic configured in IIS and ASP.NET code.

Detail Ref – MSDN


One thought on “Server.Transfer() and Response.Redirect()”

  1. Dear Friends,

    I hope you are doing well. I have launched a web site and it is basically aimed C#,JAVA,VB.NET,ASP.NET,AJAX,Sql Server,Oracle,WPF,WCF and etc resources, programming help, articles, code snippet, video demonstrations and problems solving support. I would like to invite you as an author and a supporter. Looking forward to hearing from you and hope you will join with us soon.

    Please forward this email to all of your friends who are related IT. Send to us your feed about site also.

    Thank you

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s