How to Load a Web Page Using Sockets in VB.NET

How to Load a Web Page Using Sockets in VB.NET thumbnail
Utilize sockets to load Web pages in VB.NET.

HttpWebRequest is a basic .NET class. It is contained in NameSpace System.Net. and allows users to communicate with servers based on HTTP protocol. HttpWebRequest embeds the complete HTTP protocol and it supports the Header, Content and Cookie of HTTP protocol. Thus this class enables developers to develop applications which load a Web page.

Things You'll Need

  • VB.NET
Show More

Instructions

    • 1

      Click "Start," "All Programs" and "Visual Studio." Click "File" and "New" to create a new project. Click "Visual Basic" as the programming language and "Windows Console" as the application type.

    • 2

      Enter a name for the new project and select a location for it. Click the new project on the navigation panel to open the code interface.

    • 3

      Employ the NameSpace "Systems.Net.Sockets" in the application using the following code:

      Imports Systems.Net.Sockets

      Define HttpWebRequest type variable:

      Dim httpreq AS System.Net.HttpWebRequest

      Define a URL type variable:

      Dim httpurl AS New System.Uri ("http://www.yoursite.com")

    • 4

      Enter the following code to load the Web page:

      Httpreq=CType (WebRequest.Create (httpURL), HttpWebRequest)

      Console.Writeline ("Address:" &httpreq.Address. ToString)

Related Searches:

References

  • Photo Credit Comstock/Comstock/Getty Images

Comments

Related Ads

Featured