Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want send value one to another page by server.transfer
How can I use this...?
Posted
Updated 10-May-16 23:56pm

you can use session for alternative

Session["a"]=txtUsername.Text;
Server.Transfer("Serverside.aspx")


in Serverside.aspx page

u can get this session by

Label1.Text=Session["a"],ToString();
 
Share this answer
 
Hi,

Server Side Transfer
In this method, the server will initiate the navigation like Client side browser redirect, but here the server code will simply hand over the control to some other web page so that the new page will then be rendered.
C#
Server.Transfer("path"); 

Example
C#
Server.Transfer("Serverside.aspx")


Here URL is not changed. That's because the browser had no idea that server has pushed another page for its request. Browser still thinks that it is displaying the old URL's page.
 
Share this answer
 
v2
for Example Add a Link Button in Default.aspx Page:

Step-1
ASP.NET
<asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click">Use Server.Transfer


Now under Link Button Click Event write the below code:
C# Code:


C#
protected void LinkButton1_Click(object sender, EventArgs e)
{
    HttpContext CurrContext = HttpContext.Current;
    CurrContext.Items.Add("Name","Santosh");
    CurrContext.Items.Add("Address","Bhubaneswar");
    Server.Transfer("About.aspx");

}

Now we need to catch Default page Stored Data in About page:
C# Code:

C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
 
        HttpContext CurrContext = HttpContext.Current;
        Response.Write(CurrContext.Items["Name"].ToString() + "br/");
        Response.Write(CurrContext.Items["Address"].ToString());
    }
}


Hope now you can transfer data from one page to another page using Server.Transfer Method.
 
Share this answer
 
v4
Comments
CHill60 11-May-16 6:06am    
Question was adequately answered 4 years ago.
This will show you how ans when should you use this:

Understanding Page Navigation Techniques in ASP.NET[^]
 
Share this answer
 
Actually Server.Transfer Method is not useful in many case since it will throw an error ASP0173 if we're using any sort of the Special Symbol in the Server.Transfer("pageUrl?querystring") it will throw an error asp0173 since it will not accept any sort of the Special chacters , The only one advantage of using Server.Transfer is it only forward 1 request to the server while response.redirect forwards two requests to the server.
Server.Transfer is added as an alternative to the Response.Redirect but it's limitation and drawaback never makes it popular,
If you wanted to have more secure redirection you can use Response.Write(Server.URLEncode("pageurl")); but still it has limitation if you're not using it properly , the other alternative is to use the UrlRedirect : "I am Recommanding you to use it"
Till date it is the only highly Secure Method of the Page redirect is available. you can read it at
http://www.c-sharpcorner.com/UploadFile/rohatash/url-routing-in-Asp-Net-4-0/

Thanks and Regard,
Abhinav Kumar Singh(abhinavsingh993),
Software Tester,
Goodmaysys Software Pvt. Ltd.
Lucknow.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900