Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6031717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:13:35+00:00 2026-05-23T05:13:35+00:00

I have a problem with sending a POST request from C# to a PHP

  • 0

I have a problem with sending a POST request from C# to a PHP script on my Apache (Windows) server. Everything works fine, unless I instruct Apache to require a valid user using BASIC authentication through a .htaccess file.

But let’s put things in order. I’m using the following code to send a list of key/value pairs to my PHP script using HTTP-POST:

NameValueCollection nameValues = new NameValueCollection();
nameValues["operation"] = ...;
nameValues["order"] = ...;
nameValues["status"] = ...;
nameValues["comment"] = ...;
nameValues["user"] = ...;

WebClient webClient = new WebClient();
try
{
    CredentialCache credentialCache = new CredentialCache();
    credentialCache.Add(new Uri(PERFORM_URL), "Basic", new NetworkCredential(PERFORM_USER, PERFORM_PASSWORD));

    webClient.Credentials = credentialCache;
    byte[] response = webClient.UploadValues(PERFORM_URL, "POST", nameValues);
    string responseString = Encoding.ASCII.GetString(response);
}
finally
{
    webClient.Dispose();
}

The PHP script on the server looks like this:

<?php

print_r($_SERVER);

?>

So I just output some header information here. I turn off basic authentication in my htaccess file, everything’s fine. When I turn it on, however, I get the following output:

Array
(
    ...
    [REMOTE_USER] => ****
    [AUTH_TYPE] => Basic
    [GATEWAY_INTERFACE] => CGI/1.1
    [SERVER_PROTOCOL] => HTTP/1.1
    [REQUEST_METHOD] => operation=updatestatus&order=185&status=17&comment=Test&user=somenamePOST
    [QUERY_STRING] => 
    ...
    [PHP_AUTH_USER] => ****
    [PHP_AUTH_PW] => ****
    [REQUEST_TIME] => 1286889387
    [argv] => Array
        (
        )

    [argc] => 0
)

Where, the REQUEST_METHOD contains all the parameters + the appended POST. This is wrong. What can I do about it? I’ve also read and tried solutions, where people used HttpWebRequest using the PreAuthenticate property – but that didn’t work for me either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:13:36+00:00Added an answer on May 23, 2026 at 5:13 am

    Hm. Didn’t get it to work, but implemented by own authentication, so I do not need the basic authentication anymore. Would still be interested in a working solution, in case anyone has an idea 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem. A web service is sending a JSON POST request
I have a problem with sending a JSON to a Server with REST API.
I have a client submitting a web-request (POST) of XML data to a server.
I'm having some problems with sending POST data to a PHP script with NSURLConnection.
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I am trying to make an Http POST to an Apache web server. I
I'm writing a php script that will fetch data from a given URL and
Hi I have got an ajax code as follows: $.ajax({ type:POST, url: 'sample.php', data:data=+data,
I have an access token and i want to send the POST request and
I have an application that sends messages to users. In a POST request, an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.