Search code examples
phpvb.netwebclienthttp-status-code-403

Getting Error 403 when reading from web vb.net


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


Solution

  • 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";