Getting Error 403 when reading from web vb.net

169 Views Asked by At

I have this code:

Dim address As String = "mywebsite"
Dim client As WebClient = New WebClient()
Dim webresult As String = (client.DownloadString(address))

But the last line gives an error 403. I made the PHP script and it should not do this. The PHP is

<?php

$pass="test";

if ($pass==$_GET['password']){
echo "Correct!";
} else {
echo "Incorrect!";
}

Edit: I can access it via web browsers with no problem

1

There are 1 best solutions below

1
On BEST ANSWER

I had such an issue while working in PHP. Some server configurations reject a web-request with a non-existant user-agent.

To set a user agent, do:

client.Headers["User-Agent"] = "myUserAgentString";