[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Server.Transfer

Posted on 2008-10-12
9
Medium Priority
?
1,526 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

650 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