Posting to a PHP page protected by .htaccess [RESOLVED]

Jeopardy

New member
Joined
Aug 8, 2010
Messages
2
Programming Experience
Beginner
I am trying to post data to a php script, which sits behind a .htaccess file. The problem is when the post data reaches the script, it is blank. If i remove the .htaccess, then the post data appears in the PHP script. I dont get why the protection stops the post data. The credentials are correct as it is able to access the page.

Any help will be much appreciated!

The Code:

VB.NET:
Public Function PostData(ByRef data As String, ByRef url As String) As String 

        Dim aCredentialCache = New System.Net.CredentialCache() 

        aCredentialCache.Add(New Uri("PROTECTED_DOMAIN_URL"), "Basic", New System.Net.NetworkCredential("USERNAME", "PASSWORD")) 

        Dim request As HttpWebRequest = DirectCast(WebRequest.Create(url), HttpWebRequest) 
        request.Method = "POST" 
        request.Credentials = aCredentialCache 
        request.ContentType = "application/x-www-form-urlencoded" 
        Dim postData2 As String = data 
        request.ContentLength = postData2.Length 

        Dim writer As New StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII) 
        writer.Write(postData2) 
        writer.Close() 

        Dim stream As Stream = request.GetResponse().GetResponseStream() 
        Dim reader As New StreamReader(stream) 
        Dim response As String = String.Empty 


        Return response 
    End Function

The .htaccess code:

VB.NET:
AuthUserFile "/PATH/TO/PASSWORD/FILE" 
AuthType Basic 
AuthName "URL" 
require valid-user
 
Last edited:
Have finally got it to work. If anyone wanted to know, it was to do with the way VB authenticated with the server. Instead i just added the basic authentication header
 
Back
Top