Click here to Skip to main content
Licence 
First Posted 25 Jan 2003
Views 78,596
Bookmarked 21 times

Inline Redirections in ASP.NET

By | 8 Nov 2003 | Article
Here we would discuss some simple tricks which would accelerate browsing speed of an ASP web application.

Faster Page Redirections

We normally use Response.Redirect in our ASP scripts to redirect the user from one page to another. But Response.Redirect normally sends a 302 Redirect Request to the client browser which then initiates a next HTTP Request to the server with the correct URL that the webserver might have put in the HttpHeader in the Location value. Though this gives a nice way to jump between the URLs, the catch is that it incurs a (costly) roundtrip between the HttpServer and the client browser. The simple and directly visible costs that might be visible are:

  • Slow Browsing Speed for the Client User Surfing at your Website
  • Extra Bandwidth Usage for the WebServer to serve that request.

Starting from IIS 5, ASP engine (version 3.0) provides an elegant way for this type of redirects, with a method in Server Object called Server.Transfer. Server.Transfer redirects requests to the page in the serverside itself, without additional 302 location headers to the client browser.

There is one another catch with Response.Redirect. On a very slow connection, sometimes, when the user hits the Browser Stop button, it just says

Object Moved

It may be found here

where here is hyperlinked to the URL that was contained in the 302 Redirect status line.

ASP Sample (with Response.Redirect)

Copy paste the code below into a blank new ASP page from Visual InterDev and run it from your webserver.

Note: It would be very fast from localhost and hence you might not be able to see the differences. Try out from a remote webserver instead. You need to have a blank page called remotepage.asp, in the same folder as the ASP script to which you are saving the following code snippet for the following snippets to work.

   <%
      Response.Redirect ("remotepage.asp");
   %>  

ASP Sample (with Server.Transfer)

   <%
      Server.Transfer ("remotepage.asp");
   %>  

Some Highlights

There are certain changes in Server.Transfer and Response.Redirect compared to its Classic ASP counterparts. The following may be noted.
  • Server.Transfer has an overload now, which indicates whether to preserve the form data as the processing is transferred to the new page.
  • Response.Redirect has an overload now, which indicates whether to stop execution of the current page.

NOTE:

One note however is yet to be mentioned. Since webfarms are a common feature nowadays and webfarms consist of multiple webservers serving webrequests for a particular domain, and because of my little experience and exposure to Web Farms, that area is likely to be researched and to be determined whether Server.Transfer would really help in that area too. But for that for a website/web application in ASP, hosted from a straight single webserver, this article, I hope, would surely guide you towards a most fast ASP code.

Summarizing:

Though it is just a syntax feature, highlighting a difference between Response.Redirect and Server.Transfer, it has more advantages that a costly roundtrip and waiting time for the web surfer visiting the web application is avoided. This provides a interactive browsing experience for the web user. Additionally, it may also provide some bandwidth cost savings, since most of the webhosts, who charge for the amount of data transferred through their pipes.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Vasudevan Deepak Kumar

Web Developer

India India

Member

Vasudevan Deepak Kumar is from Chennai, India who has been in the programming career since 1994, when he was 15 years old. He has his Bachelors of Engineering (in Computer Science and Engineering) from Vellore Engineering College (now VIT University). He also has a MBA in Systems from Alagappa University, Karaikudi, India.


He started his programming career with GWBasic and then in his college was involved in developing programs in Fortran, Cobol, C++. He has been developing in Microsoft technologies like ASP, SQLServer 2000. For sometime, he has also been with PHP and MySQL based development in one of his previous organizations. Now currently his focus is on Microsoft .NET World (ASP.NET, C# and Whidbey)


In his past-time, he listens to polite Carnatic Music.

Web Presence


Homepage

http://www.lavanyadeepak.tk/

Blogs



Technical




Gossips



Spiritual







Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalredirection sites Pinmembersainathkm10:03 5 Mar '05  
GeneralProblem in Server.Transfer Pinmemberfdabbagh2:34 12 Oct '03  
QuestionAdvanced? PinmemberDaniel Turini6:46 26 Jan '03  
AnswerRe: Advanced? PinmemberChristian Graus10:00 26 Jan '03  
AnswerRe: Advanced? PinmemberDeepak Kumar Vasudevan17:34 26 Jan '03  
GeneralRe: Advanced? Pinsusskcrismon17:41 23 Feb '03  
GeneralRe: Advanced? PinmemberDeepak Kumar Vasudevan17:55 23 Feb '03  
GeneralRe: Advanced? PinsussAnonymous11:04 29 Jun '03  
GeneralRe: Advanced? PinsussAnonymous0:36 16 Oct '03  
GeneralRe: Advanced? PinmemberViReNdrA KuMaR KoHli19:53 16 May '07  
AnswerRe: Advanced? PinmemberOakman3:03 13 Jun '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 9 Nov 2003
Article Copyright 2003 by Vasudevan Deepak Kumar
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid