3

What is the difference between "Request" and "Response" terminologies in ASP.net? I am using ASP.net 3.5.

Suppose I have to make somebody understand about these terms. What should i say ?

Dennis Traub
  • 50,557
  • 7
  • 93
  • 108
Pankaj
  • 9,749
  • 32
  • 139
  • 283

2 Answers2

6

The Request is what a web client sends to the web server. The Response is what the web server sends - well, in response. Both are defined in the HTTP specification. (How they are structured, what information and meta data they include, etc.)

ASP.Net encapsulates these concepts in respective classes to make them programmatically accessible.

Edit: Specific examples as requested in the comments:

Request.QueryString

If you have a URL like the following:

http://www.host.com/Page.aspx?name=Henry&lastName=Ford

The part after the ? is the query string. (name=Henry&lastName=Ford <= The query string)

This is one common way to pass arguments to the server as part of the Request. In your server code you can access these arguments by using Request.QueryString:

string name = Request.QueryString["name"];
string lastName = Request.QueryString["lastName"];

Response.Redirect

Your server received a Request for a page and you want to redirect to another location. With the Response.Redirect() method, you add a specific piece of information to the Response that causes the browser to immediately go to this other page.

// This tells the browser to load google
Response.Redirect("http://www.google.com");
Dennis Traub
  • 50,557
  • 7
  • 93
  • 108
  • so how to understand the Request.Querystring and Response.Redirect in context of above definition. Can you send the Edit in your answer ? – Pankaj Jan 06 '12 at 06:10
  • http://msdn.microsoft.com/en-us/library/system.web.httprequest.querystring%28v=VS.90%29.aspx and http://msdn.microsoft.com/en-us/library/system.web.httpresponse.redirect%28v=VS.90%29.aspx. Start reading. At some point you have to take responsibility for your own learning. – Quick Joe Smith Jan 06 '12 at 06:26
  • Can you explain more in details about Request for Request.QueryString ? – Pankaj Jan 06 '12 at 06:55
1

There is a IIS (Internet Information Services) Server.. In ASP.Net, you can Request for data from the server, and what the server sends you is a Response

Anil
  • 967
  • 10
  • 20