Reading a PHP page

sean5446

New member
Joined
Jan 9, 2008
Messages
2
Programming Experience
1-3
I have created a simple auth page at http://seano.vzz.net/stockAuth.php
Basically it just checks your IP address against a list and returns your IP address with either "Passed" or "Failed"

I want to create a vb.net function that can load the PHP page and retrieve the result

I have tried several vb.net code examples from various places and they all result in the similar errors: "404 page not found" or "301 Found"

The file is clearly existent because I can view it with Firefox....
I can also use an Inet from VB6 code to load the page - works perfectly

VB6 Working Code:

VB.NET:
Private Sub Form_Load()
Inet.RemoteHost = "seano.vzz.net/"
Inet.Document = "stockAuth.php?"

Dim s As String
s = Inet.OpenURL

MsgBox s
End Sub

Code that I'm currently using in VB.net (will load any page except the PHP one I want )

VB.NET:
Public Function getHTML(ByVal URL As String) As String
Dim myWebClient As New WebClient
Return myWebClient.DownloadString(URL)
End Function

Ive tried the asynchronous client on MSDN, Ive tried WebClient.OpenRead, Ive tried WebRequest.Create(...) with streamreader... the list goes on and on


Ive also tried modifying the URL to:

seano.vzz.net/stockAuth.php?
seano.vzz.net/stockAuth.php
http://seano.vzz.net/stockAuth?
http://seano.vzz.net/stockAuth
http://seano.vzz.net/stockAuth.php?
http://seano.vzz.net/stockAuth.php


I cant seem to get vb.net to load a php page from Host Ultra
Any ideas?
Please help me!
Thanks in Advance!
 
Last edited by a moderator:
John, thanks a lot!

the code works perfectly now - I knew it would be a small error

for anyone that wishes to use vb.net to retrieve php pages:
VB.NET:
    Public Function getHTML(ByVal URL As String) As String
        Dim myWebClient As New WebClient
        myWebClient.Headers.Add(Net.HttpRequestHeader.UserAgent, "Mozilla/4.0")
        Return myWebClient.DownloadString(URL)
    End Function
 
It is not a PHP issue, it is only the webserver that is serving seano.vzz.net that has this limitation. Filtering requests by UserAgent may be used for different purposes.
 
Back
Top