HI Guys Today I want to tell you a little bit about these two things
a)Server.Transfer : This method is same as Response.redirect Except This Method is to transfer user from one page to another page without generating a fresh httprequest,which means that transferring from one to another page is done at server.
Advantage : The Main advantage of using this method is less roundtrip time and hence good performance,because the user is transferred from one page to another page at server side rather than making request first at client side and sending this request to server side.
Disadvantage : The main disadvantage of using this method is url is not changed while sending user from one page to other page so User can be confused some time regarding application behavior. when I transferred to other page the Url didn't changed but only contents are changed.
Response.Redirect : With Response.redirect method first request in send for requested page at browser's end then the browser send this request to Server,server processes the requested and send httpresponse to browser and hence in the whole process roundtrip time is exceed as compare to Server.Transfer method.
Advantage: The main Advantage of using response.redirect is user can understand the redirect in application from one page to other page as the url change when redirecting the user.
Disadvantage : The disadvantage is rountrip time is more than server.transfer which is not good from performance perspective. you can send all those things with server.transfer which you send with response.redirect like parameteres values and receiveing them in same way as did for response.redirect.
Page1.aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("~/Page2.aspx?Id=1&Name=Vishal");
}
protected void Button2_Click(object sender, EventArgs e)
{
Response.Redirect("~/Page2.aspx?Id=1&Name=Vishal");
}
Page2.aspx.cs
lblid.Text = Request.QueryString["Id"];
lblname.Text = Request.QueryString["Name"];











0 comments:
Post a Comment