Communication between VB. NET and WEB Server

Source: Internet
Author: User
Tags ftp access

WebRequest and WebResponse are two common classes for accessing the Internet. Strictly speaking, WebRequest is an abstract base class. We generally use its response class HttpWebRequest and FileWebRequest. FTP access requires manual registration, for more information, see the insert protocol.
Logically speaking, Net classes includes three layers: Request/response layer, application protocol layer, and transmission layer, which are sequentially expanded from application to network. The WebRequest and WebResponse classes represent the request/response layer. HTTP, TCP, and UDP constitute the application protocol layer, and sockets exist in the transport layer. WebRequest/WebResponse and HTTP can be found in the System. Net namespace, while TCP/UDP and socket are in the System. Net. Sockets namespace, including commonly used UDPClient and TCPCLient.
WebRequest and WebResponse (Request/Response Model)

The request/response model is located at the top, providing a simple way to access resources on the Web. WebRequest is an abstract base class of the. NET Framework for Request/response models used to access Internet data. Applications using this request/response model can request data from the Internet in an unknown protocol? The Protocol is not specific.
These two types provide a general way to access online resources. WebRequest indicates a network request that contains attributes such as RequestURI, Headers, Credentials, and ContentType. The main methods on WebRequest include GetRequestStream, GetResponse, and Their Asynchronous methods Begin/EndGetRequestStream and Begin/EndGetResponse.
GetRequestStream is used to obtain a stream to upload data to the server. GetResponse is used to obtain the response object returned by the server. WebResponse indicates the response received from the server that processes the request. Its key attributes include ContentLength, ContentType, headers, ResponseURI, and Status. The most common method on WebResponse is GetResponseStream, which is used to read (download) data from the server.
 
When calling WebRequest. GetResponse, the actual network request is usually sent.
This example shows how to obtain a Web page and output its content:
Dim url As New Uri ("http://www.yahoo.com") 'defines a URI

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.