dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Difference between Resonse.Redirect and Server.Transfer.

  1. #1
    Join Date
    Dec 2018
    Posts
    15

    Difference between Resonse.Redirect and Server.Transfer.

    In ASP.Net Technology both "Server" and "Response" are objects of ASP.Net. Server.Transfer and Response.Redirect both are used to transfer a user from one page to another. But there is some remarkable differences between both the objects which are as follow.

    Response.Redirect
    1. Response.Redirect() will send you to a new page, update the address bar and add it to the Browser History. On your browser you can click back.
    2. It redirects the request to some plain HTML pages on our server or to some other web server.
    3. It causes additional roundtrips to the server on each request.
    4. It doesnít preserve Query String and Form Variables from the original request.
    5. It enables to see the new redirected URL where it is redirected in the browser (and be able to bookmark it if itís necessary).
    6. Response. Redirect simply sends a message down to the (HTTP 302) browser.

    Server.Transfer
    1. Server.Transfer() does not change the address bar, we cannot hit back.One should use Server.Transfer() when he/she doesnít want the user to see where he is going. Sometime on a "loading" type page.
    2. It transfers current page request to another .aspx page on the same server.
    3. It preserves server resources and avoids the unnecessary roundtrips to the server.
    4. It preserves Query String and Form Variables (optionally).
    5. It doesnít show the real URL where it redirects the request in the users Web Browser.
    6. Server.Transfer happens without the browser knowing anything, the browser request a page, but the server returns the content of another.

  2. #2
    Join Date
    Jan 2019
    Location
    Slough
    Posts
    20

    Re: Difference between Resonse.Redirect and Server.Transfer.

    Resonse.Redirect and Server.Transfer. both methods are used to transfer a user from one web page to another web page. Both methods are use for the same purpose but still there are some differences.
    The Response.Redirect method redirects a request to a new URL and specifies the new URL while the Server.Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page.

  3. #3
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,058

    Re: Difference between Resonse.Redirect and Server.Transfer.

    Quote Originally Posted by John Aeliya View Post
    Resonse.Redirect and Server.Transfer. both methods are used to transfer a user from one web page to another web page. Both methods are use for the same purpose but still there are some differences.
    The Response.Redirect method redirects a request to a new URL and specifies the new URL while the Server.Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page.
    What does 'terminate' mean in your answer? I mean they both leave the first page, but I don't see what you mean by termination the page in the transfer case.

  4. #4

    Re: Difference between Resonse.Redirect and Server.Transfer.

    Response.Redirect should be used when:
    we want to redirect the request to some plain HTML pages on our server or to some other web server
    we don't care about causing additional roundtrips to the server on each request
    we do not need to preserve Query String and Form Variables from the original request
    we want our users to be able to see the new redirected URL where he is redirected in his browser (and be able to bookmark it if its
    necessary)

    Server.Transfer should be used when:

    we want to transfer current page request to another .aspx page on the same server
    we want to preserve server resources and avoid the unnecessary roundtrips to the server
    we want to preserve Query String and Form Variables (optionally)
    we don't need to show the real URL where we redirected the request in the users Web Browser

  5. #5
    Join Date
    May 2019
    Location
    601 & 612, The Times square Arcade, Near Baghban party plot, Thaltej - Shilaj Rd, Thaltej, Ahmedabad, Gujarat 380059, India
    Posts
    7

    Post Re: Difference between Resonse.Redirect and Server.Transfer.

    Both Response.Redirect and Server.Transfer methods are used to transfer a user from one web page to another web page. Both methods are used for the same purpose but still there are some differences as follows.

    The Response.Redirect method redirects a request to a new URL and specifies the new URL while the Server.Transfer method for the current request, terminates execution of the current page and starts execution of a new page using the specified URL path of the page.

    Both Response.Redirect and Server.Transfer has the same syntax like:

    Response.Redirect("UserDetail.aspx");
    Server.Transfer("UserDetail.aspx");

    Server.Tarnsfer sends a request directly to the web server and the web server delivers the response to the browser.
    Response.Redirect can be used for both .aspx and HTML pages whereas Server.Transfer can be used only for .aspx pages and is specific to ASP and ASP.NET.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)