4.
1 Client server Communication
4.1Wer Server-web browser communication
4.2 Predefined objects of Asp.Net
4.2.1 Request
When a browser asks for a page from server, it is called a request. The Request object
used to get information from a client.
4.2.1 Response
The Response object is used to send output to the user from the sever.it was the only
way to write data to the page.
4.2.1 Server
This object is the instance of the system.web.HttpServerUtility class. It provides
MachineName Property which provides the name of the computer on which the page is
running.
“Server.Transfer”, following is the sequence of how the transfer happens:
1. User sends a request to an ASP.NET page. In the below figure, the request is sent to
“WebForm1” and we would like to navigate to “Webform2”.
2. Server starts executing “Webform1” and the life cycle of the page starts. But before the
complete life cycle of the page is completed, “Server.transfer” happens to “WebForm2”.
3. “Webform2” page object is created, full page life cycle is executed and output HTML response
is then sent to the browser.
“Response. Redirect”, following is the sequence of events for navigation:
1. Client (browser) sends a request to a page. In the below figure, the request is sent to
“WebForm1” and we would like to navigate to “Webform2”.
2. Life cycle of “Webform1” starts executing. But in between the life cycle “Response.Redirect”
happens.
3. Now rather than server doing a redirect, he sends a HTTP 302 command to the browser. This
command tells the browser that he has to redirect to “Webform2.aspx” page.
4. Browser interprets the 302 command and sends a GET request for “Webform2.aspx”.
• “Server.Transfer” is executed by the server while “Response.Redirect” is executed by
the browser.
• “Response.Redirect” needs two requests to do a redirect of the page.
So When to Use “Server.Transfer” and When to Use “Response.Redirect”?
• Use “Server.Transfer” when you want to navigate pages which reside on the same
server,
• use “Response.Redirect” when you want to navigate between pages which resides on
different server and domain.
.
Server.Transfer Response.Redirect
Redirection Redirection is done by the server. Redirection is done by the browser client.
Browser
Does not change. Changes to the redirected target page.
URL
When to Redirect between pages of the Redirect between pages on different server
use same server. and domain.
https://www.facebook.com/DotNetInterviewQuestions/videos/vb.341019362605680/7621861
50488997/?type=2&theater