Networking VB.NET (Web Request, Web Respons, URI Class)

Tutorial belajar vb.net : Networking VB.NET - WebRequest, HttpWebRequest, request.GetType(), response.ContentLength, response.ContentType, WebResponse, URI Class dalam vb.net

Belajar Vb.Net Pemula - Pelajaran vb.net tentang Networking class yang bisa digunakan para depelover aplikasi vb.net diantaranya Class WebRequest, HttpWebRequest, request.GetType(), response.ContentLength, response.ContentType, WebResponse, Download data dari URI Class dalam vb.net, baca Penggunaan HttpWebRequest Class, HttpWebResponse Vb.Net, Tutorial kali ini merupakan kelanjutan dari postingan sebelumnya yang akan membahas secara detail tentang  Penggunaan Class WebRequest dan WebResponse dalam mendownload Data dari sebuah URI, Menampilkan Respon dari sebuah class webRequest, Searching dengan Google, mengetahui apakah koneksi website ada atau tidak, dan yang terakhir tentang Web Request dan Response: type serta content type  length dalam VB.Net. simak terus tutorialnya ya.

Buatlah sebuah project aplikasi console untuk memudahkan kamu untuk belajar, ikuti step - by - step tutorial Networking VB.NET (Web Request, Web Respons, URI Class) ini :
Networking VB.NET (Web Request, Web Respons, URI Class)

Download Data dari class URI

Imports System.IO
Imports System.Net
Module Module1
    Sub Main()
        Dim Geturi As Uri
        Dim Getrequest As WebRequest
        Dim Getresponse As WebResponse
        Dim Getstream As Stream
        Dim Getreader As StreamReader
        Dim Getdata As String
        Geturi = New Uri("https://www.facebook.com/SectorsCode")

        Getrequest = WebRequest.Create(Geturi)
        Getresponse = Getrequest.GetResponse()
        Getstream = Getresponse.GetResponseStream()
        Getreader = New StreamReader(Getstream)
        Getdata = Getreader.ReadToEnd()
        Getreader.Close()
        Getstream.Close()
        Console.WriteLine(Getdata)
        Console.WriteLine("=================================")
        Console.WriteLine("Get data Success!")
        Console.ReadKey()
    End Sub

End Module

Mendapatkan Response dari WebRequest

Imports System.IO
Imports System.Net
Module Module1
    Sub Main()
        Dim CreateRequest As HttpWebRequest
        Dim GetResponse As WebResponse
        Dim GetReader As StreamReader
        Dim GetString As String
        CreateRequest = WebRequest.Create("https://www.facebook.com/SectorsCode")
        GetResponse = CreateRequest.GetResponse()
        GetReader = New StreamReader(GetResponse.GetResponseStream())
        GetString = GetReader.ReadToEnd()
        GetReader.Close()
        Console.WriteLine(GetString)
        Console.ReadKey()
    End Sub

End Module

Baca dari Web Client

Imports System.IO
Imports System.Net
Public Class Class1
    Public Property HttpUtility As Object
    Public Function Define(ByVal word As String) _
        As String()
        Dim Getrequest As HttpWebRequest = Nothing
        Dim Getrespons As HttpWebResponse
        Dim Createquery As String
        Dim Getresult As New List(Of String)
        Createquery = "https://www.google.com/search?q=scqq" _
        & HttpUtility.UrlEncode(word)
        Try
            Getrequest = DirectCast(WebRequest.Create(Createquery),
                HttpWebRequest)
            With Getrequest
                .Method = "GET"
                Getrespons = Getrequest.GetResponse
                If Getrespons.StatusCode = HttpStatusCode.OK Then
                    ParseResponse(Getrespons.GetResponseStream,
                                  Getresult)
                Else
                    System.Console.WriteLine("Error " _
                    + "calling definition service")
                End If
            End With
        Catch ex As Exception
            System.Console.WriteLine("Error getting definitions")
        End Try
        Return Getresult.ToArray()
    End Function
    Private Sub ParseResponse(ByVal input As _
        System.IO.Stream, ByRef output As List(Of String))
        Dim Getreader As New StreamReader(input)
        Dim Dowork As String = Getreader.ReadToEnd
        System.Console.WriteLine(Dowork)
    End Sub
End Class

Cek apakah Koneksi Available atau tidak

Imports System.Net
Module Module1
    Public Function IsConnectionAvailable() As Boolean
        Dim CreateUrl As Uri
        Dim Createreq As WebRequest
        Dim Getrespons As WebResponse
        CreateUrl = New Uri("http://scqq.blogspot.com/")
        Createreq = WebRequest.Create(CreateUrl)
        Try
            Getrespons = Createreq.GetResponse
            Getrespons.Close()
            Createreq = Nothing
            Return True
        Catch ex As Exception
            Return False
        End Try
    End Function
    Sub Main()
        Console.WriteLine("Cek koneksi ke 'http://scqq.blogspot.com'")
        Console.WriteLine(IsConnectionAvailable())
        Console.ReadKey()
    End Sub

End Module

Baca Type Request dan Response

Imports System.Net
Module Module1
    Sub Main()
        Dim Createuri As Uri
        Dim Createrequest As WebRequest
        Dim Getresponse As WebResponse
        Createuri = New Uri("http://scqq.blogspot.com/")
        Createrequest = WebRequest.Create(Createuri)
        Getresponse = Createrequest.GetResponse()
        Console.WriteLine("Request type: " & Createrequest.GetType().ToString())
        Console.WriteLine("Response type: " & Getresponse.GetType().ToString())
        Console.WriteLine("Content length: " & Getresponse.ContentLength & " bytes")
        Console.WriteLine("Content type: " & Getresponse.ContentType)
        Console.ReadKey()
    End Sub

End Module

COMMENTS

Next Recomended


Feel free to code it up and send us a pull request.

Hi everyone, let's me know how much this lesson can help your work. Please Subscribe and Follow Our Social Media 'kodeajaib[dot]com' to get Latest tutorials and will be send to your email everyday for free!, Just hit a comment if you have confused. Nice to meet you and Happy coding :) all ^^



Follow by E-Mail


Name

ADO.NET,3,Ajax,6,Android,9,AngularJS,4,ASP.NET,4,Blogger Tutorials,7,Bootstrap,7,C++,1,Codeigniter,2,Cplusplus,6,Crystal Report,6,CSharp,25,Ebook Java,2,FlyExam,1,FSharp,3,Game Development,2,Java,35,JDBC,2,Laravel,84,Lumen,2,MariaDB,2,Ms Access,3,MySQL,31,ODBC,6,OleDB,1,PHP,14,PHP Framework,5,PHP MYSQLI,9,PHP OOP,5,Python,8,Python 3,4,SQL Server,4,SQLite,4,Uncategorized,5,Vb 6,2,Vb.Net,89,Video,48,Vue Js,4,WPF,2,Yii,3,
ltr
item
KODE AJAIB: Networking VB.NET (Web Request, Web Respons, URI Class)
Networking VB.NET (Web Request, Web Respons, URI Class)
Tutorial belajar vb.net : Networking VB.NET - WebRequest, HttpWebRequest, request.GetType(), response.ContentLength, response.ContentType, WebResponse, URI Class dalam vb.net
http://3.bp.blogspot.com/-w4-6g3gb4Bo/Vko6nLppI7I/AAAAAAAABM8/L7IxwlCT6T8/s320/networking-vbnet.jpg
http://3.bp.blogspot.com/-w4-6g3gb4Bo/Vko6nLppI7I/AAAAAAAABM8/L7IxwlCT6T8/s72-c/networking-vbnet.jpg
KODE AJAIB
https://www.kodeajaib.com/2015/11/networking-vbnet-web-request-uri.html
https://www.kodeajaib.com/
https://www.kodeajaib.com/
https://www.kodeajaib.com/2015/11/networking-vbnet-web-request-uri.html
true
3214704946184383982
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy