Friday 18 May 2012

Difference between Server.Transfer() and Server.Execute()

The HttpServerUtility.Execute method executes a request to another page using the specified URL path to the page. The Execute method continues execution of the original page after execution of the new page is completed.
e.g.
Server.Execute(“ProcessTestAnswers.aspx”) ;

Server.transfer : 
Terminates execution of the current page and begins execution of a new page for the current request.
The page transferred to should be another Web Forms page (.aspx page) in the same application. You cannot use Server.Transfer to redirect to an .asp or .asmx page. Make sure that the target page exists. Because Server.Transfer is executed on the server, the browser does not have a record of the page change. Therefore, if the user refreshes the page, unexpected results can occur.
e.g.
Server.Transfer("Logon.aspx");




server.transfer method will transfers the execution from current ASPX page to specified ASPX page in the same webserver whereas 
server.execute method allows the current ASPX page to execute specified ASPX page in the same webserver, when it finishes the execution of the specified page, control will return back to same point where server.execute method is called and continues the further process.

No comments:

Post a Comment