?
Solved

Server.Transfer

Posted on 2008-10-12
9
Medium Priority
?
1,522 Views
Last Modified: 2012-06-27
I searched Google to find difference between Response.ReDirect and Server.Transfer. I found many links but articles are confusing. It is still not very clear:

(1) In which situations to use Server.Transfer?
(2) When the page is about to restore its view state and during that time the connection with the server breaks, what will happen? Will the view state be successfully restored?
(3) Does Response.Redirect refreshed memory on each call and it is not possible to access last page contents?
0
Comment
Question by:rpkhare
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 
LVL 5

Accepted Solution

by:
varungd earned 75 total points
ID: 22700358
Use below given  codes and check your URL after redirect the page. You can understand the difference. While using Server.Transfer URL is not updating.

Response.Redirect("Webform1.aspx");
Server.Transfer("Webform1.aspx");
0
 
LVL 8

Author Comment

by:rpkhare
ID: 22700413
Ok that I have experimented. What are the specific situations where Server.Transfer is to be used?
0
 
LVL 7

Assisted Solution

by:ajolly
ajolly earned 75 total points
ID: 22700530
1. Server.Transfer does not update the URL in the address bar, so you should not use it when you want the URL to be the URL of the page where you are.

2. Server.Transfer is faster than Response.Redirect. So if you need the faster response and you don't worry about point 1 then use Server.Transfer.

3. Server.Transfer can not transfer to the different server. You can not use Server.Transfer to transfer from your page to yahoo.com or somewhat like that. But Response.Redirect can redirect you to any valid URL.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 8

Author Comment

by:rpkhare
ID: 22700589
What about the answer to question 2 in my original post?
0
 
LVL 7

Expert Comment

by:ajolly
ID: 22700622
its an atomic process.
its done fully or not at all. If you viewstate data was transferred to the server fully, it will not save. If it is transferred to the server and then the link breaks, not an issue, it will be saved.
0
 
LVL 13

Assisted Solution

by:TechTiger007
TechTiger007 earned 75 total points
ID: 22701253
The real difference between server.transer and response.redirect is this
When you call Response.Redirect your source code will stops execution and sends a response to the web browser to open the redirect URL specified. So your browser will update the URL displayed and sends a new request to the URL. So in this case there is an extra round trip or request

When you call server.transfer, asp.net will stop execution of the current page and start processing the page in new URL and send the response back to the web browser. So the browser is unaware of a change in URL here Hence the URL is not updated. There is no extra round trip in this case.

Since an asp.net process can execute code which is under the same site, you can use server.transfer to transfer control to any page within that site.
In case of Response.Redirect you are just saying the browser to open a new page, hence you can give any URL here.

Hope that clarifies
0
 
LVL 8

Author Comment

by:rpkhare
ID: 22701339
In my site, I am using SiteMap to display menu and from there accessibility to various web pages. In this case how to use Server.Transfer? I think it is using Response.Redirect by default. See the attached code:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="MenuPage.aspx" title="Main Menu"  description="Menu Page">
      <siteMapNode url="" title ="Masters" description="Master Settings">
        <siteMapNode url="ItemMaster.aspx" title="Item Master"  description="" />
        <siteMapNode url="PartyMaster.aspx" title="Party Master"  description="" />
        <siteMapNode url="CategoryMaster.aspx" title="Category Master"  description="" />
      </siteMapNode>
      <siteMapNode url="" title="Tasks"  description="">
        <siteMapNode url="" title="New Bill"  description="" />
        <siteMapNode url="" title="Stock Entry"  description="" />
      </siteMapNode>
    </siteMapNode>
  
</siteMap>

Open in new window

0
 
LVL 13

Expert Comment

by:TechTiger007
ID: 22701514
This will not be using Server.Transfer or Response.Redirect. Your browser will be sending a new request to server. Response.Redirect or Server.Transfer will be useful when you are already processing a page in your code behind and in the middle of execution you decide to pass the control to another page based on some value (query string, database entry, etc)


0
 
LVL 23

Expert Comment

by:Tony McCreath
ID: 22701635
Server.Transfer does not support querystrings in the transfer url.

There are ways around this, but nothing nice as far as I know.

It can make it quite hard to use as a redirect tool.

Another related method is to use HttpModules and url mapping.

Could you clarify how you plan on using your sitemap and why you feel redirects or transfers are needed.
 
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question