Cheap Hosting Domain Names

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Monday, 23 April 2012

Response.Redirect vs Server.Transfer: What to use when? An 11 point comparision

Posted on 08:52 by Unknown
1. Response.Redirect simply sends a message to the browser, directing it to move to another page.

Example:

Response.Redirect("default.aspx");
or
Response.Redirect("
http://www.dzone.com");

On the other hand, Server.Transfer does not initiate another request to the server, but the original request is simply rewritten and transfered to some other page on the same server.

Example: Sever.Transfer("default.aspx");

2. Server.Transfer changes the "focus" on the Webserver and transfers the request. This means you don't get quite as many HTTP requests coming through, which therefore eases the pressure on your Web server and makes your applications run faster. On the other hand, Response.Redirect will instruct browser to call a particular webpage.This will increase one request and one response between the client and server. This extra round-trip is often inefficient and unnecessary.

3. Server.Transfer maintains the original URL in the browser but Response.Redirect changes the URL.

4. The Server.Transfer method also has a second parameter—"preserveForm". If you set this to True, using a statement such as Server.Transfer("default.aspx", True), the existing query string and any form variables will still be available to the page you are transferring to. By default, this variable is always true.

For example, if your default.aspx has a TextBox control called "TextBox1" and you transferred to default2.aspx with the preserveForm parameter set to True, you would be able to retrieve value of the "TextBox1" of default.aspx by using "PreviousPage.FindControl" method.
But in case of Respons.Redirect, by the time default2.aspx is requested, default.aspx is flushed from the server’s memory and no information can be retrieved about it unless the developer explicitly saved the information using some technique like session, cookie, application, cache etc.

5. By Response.Redirect, we can navigate to another page in same site as well as different site, but by Server.Transfer we can only navigate the page that exists in same website.

6. Server .Transfer will also cause confusion when user refreshes the page. If user is on Page1 and by using Server.Transfer, user sees the Page2. The url on browser is still of Page1. So, if user refreshes the page, Page1 will be refreshed instead of Page2. This problem will never appear in case of Response.Redirect.

7. Server.Transfer may cause confusion while debugging as the URL does not change unlike Response.Redirect.

8. Response.Redirect is used like GET method in which we can see all information or address where we will be go. Server.Transfer is used like POST method in which one cannot see full address.

9. Resonse.redirect can be used both for aspx and html pages. But server.transfer is only used for aspx pages it will not work for html pages.

10. In case of Server.Transfer the browser's history is not updated but in Response.Redirect the browser's history is updated.

11. Bookmarking is ambiguous in case of Server.Transfer while in Response.Redirect, user can clearly bookmark a page.

Summary: What should be used where?

Response.Redirect should be used when:

1. We want to redirect the request to some plain HTML pages on our server or to some other web server.
2. We don't care about causing additional roundtrips to the server on each request.
3. We do not need to preserve Query String and Form Variables from the original request.
4. 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:

1. We want to transfer current page request to another .aspx page on the same server.
2. We want to preserve server resources and avoid the unnecessary roundtrips to the server.
3. We want to preserve Query String and Form Variables.
4. We don't need to show the real URL where we redirected the request in the users Web Browser
 
Email ThisBlogThis!Share to XShare to Facebook
Posted in DOTNET | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Online Religion Degrees
    Religion plays a major role in the historical, political, and cultural life of our societies. If you are fascinated by belief systems, consi...
  • How to create dynamic tables in HTML using javascript at runtime?
    In this tutorial, you will come to know how to create dynamic tables in HTML. There are some situations when you don't know the contents...
  • Online Economics Degrees
    Economists research and analyze economics, or the way people choose to use their resources to produce goods and services. Economists typical...
  • Online Advertising Degrees
    The objective of any business firm is to market and sell its products or services profitably. In small firms, the owner or chief executive o...
  • Online Geography Degrees
    With the growth of online colleges and universities, geography degrees online have gained immense importance. Geography degrees online can b...
  • Online DBA (Database Administrator) Degrees
    Database managers keep vital information organized.  With a database technology degree, you may find yourself organizing customer informatio...
  • Online Social Science Degrees
    Social science covers a broad range of fields: behavioral science, history, economics, geography, political science, women''s studie...
  • Difference between page_init, page_load and page_prerender events
    page_init This event is the first event to occur when an ASP.NET page is executed. This is the event where you should be performing any init...
  • Online BCA Degrees
    The boom in the IT industry has opened up plenty of job opportunities for computer professionals. As a result, computer application courses ...
  • Online Professional Degrees
    Going back to get more education can be a difficult, time consuming and sometimes impossible proposition. But with new advances in virtual t...

Categories

  • AJAX
  • C++
  • CSS
  • Delphi
  • DOTNET
  • HTML
  • Javascript
  • jQuery
  • Management
  • Online Degrees
  • Oracle
  • Others
  • Phonegap
  • PHP
  • Unix
  • XML

Blog Archive

  • ▼  2012 (180)
    • ►  September (89)
    • ►  August (11)
    • ►  July (4)
    • ►  June (3)
    • ►  May (25)
    • ▼  April (48)
      • DOM Events: Mouse Events, Keyboard Events, Form Ev...
      • What is DOM (Document Object Model): Tree and Node...
      • DocType: Strict, Transitional and Frameset
      • How the ASP.NET authentication process works?
      • Response.Redirect vs Server.Transfer: What to use ...
      • GET vs POST: Which one is better? A 10 point compa...
      • HTTP vs HTTPS: Similarities and Differences
      • How IIS processes ASP.NET request?
      • AutoEventWireup in ASP.NET: Why my ASP.NET events ...
      • Web Farms in ASP.NET: Advantages and Issues
      • Cautions while dropping a tablespace
      • 12 Point Comparision between FTP and HTTP Protocol...
      • Dataset, Dataview, Datatable and common operations...
      • Client Side State Management in ASP.NET
      • Difference between page_init, page_load and page_p...
      • Database FLASHBACK mode: Overview
      • Database ARCHIVELOG mode: Overview
      • Hash Collision Attacks in .NET
      • ADO.NET: A quick revision
      • What is SQL Injection?
      • What is ASP.NET AJAX?
      • What is DLL HELL?
      • DIV vs TABLE tag: Which one to use?
      • Exception Handling in ASP.NET
      • Business Intelligence (BI): Data Warehouse, Data M...
      • UDDI: Universal Description, Discovery and Integra...
      • Web Services: Exposing and Consuming
      • Web Service Description Language
      • Simple Object Access Protocol
      • Caching in ASP.NET
      • Partial Classes in ASP.NET
      • Difference between DLL and EXE Files
      • What is an ASP.NET User Control?
      • Page Directive in ASP.NET
      • DOTNET Framework: CLR, CTS and CLS
      • What is Tethering and Hotspot?
      • Preventing Caching in AJAX URLs
      • What is web.config file? What is the significance ...
      • HTML vs XHTML vs DHTML
      • AJAX - A quick revision
      • Web Server vs Application Server vs Database Server
      • Difference Between ASP.NET Server Controls and HTM...
      • web.config vs app.config vs machine.config
      • Assemblies in .NET Framework
      • Silver Bullets for Testing
      • Unix Commands which should be on tips of each deve...
      • Basics of IBM Websphere MQ (Part 1)
      • What is Garbage Collector? How and when does it run?
Powered by Blogger.

About Me

Unknown
View my complete profile