Use of Request and Response in ASP.Net

后端 未结 2 1831
暗喜
暗喜 2021-01-21 01:03

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

Suppose I have to make so

相关标签:
2条回答
  • 2021-01-21 01:38

    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

    0 讨论(0)
  • 2021-01-21 01:44

    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");
    
    0 讨论(0)
提交回复
热议问题